[svn:perlfaq] r12288 - perlfaq/trunk
[email protected] Sat, 27 Dec 2008 06:17:37 -0800 (PST)
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
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.