Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RFC: Converted Fiscal5253 from Classic OO Perl to Moo

by boftx (Deacon)
on Jul 03, 2014 at 02:53 UTC ( [id://1092078]=perlmeditation: print w/replies, xml ) Need Help??

I have just finished converting DateTimeX::Fiscal::Fiscal5253 from classic OO Perl to Moo. I would greatly appreciate any comments that result from taking a look at the changes. The test suite required almost no changes (mainly tightening up) so I am fairly confident that I have it close to being correct.

You can find the Moo branch here on GitHub: https://github.com/boftx/DateTimeX-Fiscal-Fiscal5253/tree/moo-delegation (The current release is in the master branch as one might suppose.)

I would like to get some feedback before I release even as a devel version since I am fairly certain it will pass the CPAN testers without a problem as it is passing a make disttest on my platform.

Update: Of special interest is that I had to place a modifier on "new" in order to force "new" to be a class-only method. That is, to ensure that one could not call it as $obj->new. This works as desired, but what is interesting is that the call to before new must come after the code for BUILDARGS or else the returned arg list from that gets blown up somehow before the object is instantiated.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Replies are listed 'Best First'.
Re: RFC: Converted Fiscal5253 from Classic OO Perl to Moo
by tobyink (Canon) on Jul 03, 2014 at 11:32 UTC

    Not a massive fan of the before new bit. This is something that I think ought to be handled in Moo itself; either by making $instance->new(%params) do something useful, or by making it die with a sensible error message.

    Not sure what lines 8 and 9 are supposed to be doing. Did you put them in for debugging and forget to remove them?

    # lines 8 and 9... use Data::Dumper; $Data::Dumper::Indent = 1;

    Other than that, looks good.

    I like the use of coderefs for private methods. I've been using this technique increasingly myself, having found the "private methods begin with an underscore" convention inadequate (too easy to accidentally override private methods in a superclass).

    When I write about methods in my book I plan on promoting a four-level method privacy convention similar to .NET (private/protected/friend/public). Private methods would be coderefs in lexical variables.

      Thanks for the feedback! Yeah, that was debugging I overlooked (again.) I'm somewhat notorious for that particular oversight at $work. I'm looking at the code to see if I can do something better than before new in a trait or role or whatever after hearing what others have said. Until then, it will work (hopefully.)
      You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1092078]
Approved by Athanasius
Front-paged by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found