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.


In reply to Re: Class::MethodMaker and Class::Accessor by jbert
in thread Class::MethodMaker and Class::Accessor by kulls

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.