Most of what Moo faciliates is in the constructor, and most of the tooling of Moo is for creating fancy helpers for constructors.

From my own practice, I can't confirm this (and I also heavily disagree with Tadeusz on the topic). When working with my old Moo(se) code, I find it very helpful that the modules have a clear optical distinction between the dumb data (the has () stuff) and the object methods which actually do things (the sub foo { ...; } things). Maintaining that distinction without Moo(se) needs more discipline than I usually have during my hacking nights.

There is some truth in this if the objects are mainly just dumb data containers which don't have methods beyond the accessors. Not having to write code for these is a nice benefit, but you may put this into the category "fancy helpers for constructors". I find these container objects a lot when working with database-heavy stuff. And if the other side is a web application, decent parameter validation makes sense.

I'm using other fancy helpers for constructors like coercion and BUILDARGS almost exclusively when I want to retain the API from a non-Moose constructor to avoid version dependencies.

On the other hand, I have programs where attributes and accessors are almost exclusively used from within the module itself and external uses are through "higher level" functions. For such programs, object inheritance with its method modifiers and in particular roles play a much greater role than the constructor which in itself sometimes is used only internally, exposing factory functions to the outside. Users of these modules (well, mostly I myself) don't even need to know the attributes, but as a developer I'm happy to have them around for debugging.


In reply to Re^4: If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see? by haj
in thread If Perl 5 were to become Perl 7, what (backward-compatible) features would you want to see? by haukex

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.