|Do you know where your variables are?|
Class::Accessor and Damian's PBPby cbrandtbuffalo (Deacon)
|on Feb 22, 2006 at 16:09 UTC||Need Help??|
cbrandtbuffalo has asked for the
wisdom of the Perl Monks concerning the following question:
Class::Accessor is a very cool module and eliminates some of the drudgery of Perl OO programming. It auto-creates accessors in the common Perl way, that is, it sets if you pass it something and gets if you don't.
In Damian's Perl Best Practices, he recommends separate get and set methods with the prefix set_ and get_ to make it explicit what you intend to do.
Now, part of why he recommends this is to avoid the omission of errors when you try to set something that you don't want set. Class::Accessor takes care of this with read-only methods, so at least you would get an error.
To make the module follow Damian's suggestion, would it be a matter of making it generate get_ and set_ methods? Has someone already addressed this somewhere and I'm missing it?
I believe Class::Std handles this for inside-out objects, but I'm looking for a way to follow the suggested practice for old-fashioned perl objects (without writing all those accessors myself).