The docs for Class::Accessor contain this nugget:
"What makes this module special compared to all the other method generating modules ("SEE ALSO")? By overriding the get() and set() methods you can alter the behavior of the accessors class-wide. Also, the accessors are implemented as closures which should cost a bit less memory than most other solutions which generate a new method for each accessor."
With Class::MethodMaker being listed in the SEE ALSO section.
As to which is best, or, more generally, which is currently the "best" way to do OO in modern perl5, I don't have a good answer, although it has been discussed a bit on perlmonks. Personally, I probably tend to use Class::Accessor, simply because it is the one I picked up first.
I think this is a case where there is a bit too much TIMTOWDI, but I don't know how to best resolve it.*
* - of course, "pick one and stick with it" or "do a survey of all possible ones and choose that" or "ask for help on perlmonks and take the answer people agree most on" are all working strategies, but the latter doesn't scale too well. But I think that the main problem (maybe I'm wrong and it isn't a problem) is for people coming from other languages. They want to do OO, but the un-aided ways are a bit clunky and choosing one of the aided ways can be confusing. |