FAQ
Author: comdog
Date: Sat Dec 27 06:17:36 2008
New Revision: 12288

Modified:
perlfaq/trunk/perlfaq4.pod

Log:
* perlfaq4: How do I define methods for every class/object?
+ Ben Morrow explains the dangers in doing this.


Modified: perlfaq/trunk/perlfaq4.pod
==============================================================================
--- perlfaq/trunk/perlfaq4.pod (original)
+++ perlfaq/trunk/perlfaq4.pod Sat Dec 27 06:17:36 2008
@@ -2460,8 +2460,15 @@

=head2 How do I define methods for every class/object?

-Use the C<UNIVERSAL> class (see L<UNIVERSAL>).
+(contributed by Ben Morrow)

+You can use the C<UNIVERSAL> class (see L<UNIVERSAL>). However, please
+be very careful to consider the consequences of doing this: adding
+methods to every object is very likely to have unintended
+consequences. If possible, it would be better to have all your object
+inherit from some common base class, or to use an object system like
+Moose that supports roles.
+
=head2 How do I verify a credit card checksum?

Get the C<Business::CreditCard> module from CPAN.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcvs-perlfaq @
categoriesperl
postedDec 27, '08 at 2:17p
activeDec 27, '08 at 2:17p
posts1
users1
websitelearn.perl.org...

1 user in discussion

Comdog: 1 post

People

Translate

site design / logo © 2019 Grokbase