![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
If you have so many accessible properties that you need to generate accessors for them, you may need to re-think your design. Accessors are a code smell. I'm not sure that I entirely agree with that assertion. Most OO classes will have a number of properties, but unfortunately Perl's object model does not provide a standard way to define those properties. The simple and common approach is to store properties as keys in a hash but this leads to hard-to-find bugs resulting from typos in hash keys. Generating accessors is an effective way to eliminate that class of error. I do agree that lots of accessors in the public API of a class is often a problem with the design. The examples on the page you linked to seem to be written in a language that, unlike Perl, supports both properties and private methods. In reply to Re^2: Class::Accessor and Damian's PBP
by grantm
|
|