good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: Class::Accessor and Damian's PBPby grantm (Parson) |
on Feb 23, 2006 at 00:49 UTC ( [id://532126]=note: 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 Section
Seekers of Perl Wisdom
|
|