The more, the merrier. Personally, I like the minionize($hashref) option better, mostly because it avoids creating two packages for every class I want.

The implementation of the methods passed as anonymous subroutines in the %Class hash seems a bit difficult to read though. Still, this could probably be avoided:

use Minions (); my %Method; # maybe this hash could be already imported into # the namespace with a param passed to Minions my %Class = ( name => 'Counter', interface => [qw( next )], implementation => { methods => { next => $Method{'next'}, }, has => { count => { default => 0 }, }, }, ); $Method{'next'} = sub { my ($self) = @_; # maybe this could be avoided with some sugar $self->{-count}++; }; Minions->minionize(\%Class);

If there would be some more sugar to facilitate writing the package this way, I would like it even more. Is the line interface => [qw( next )], needed? Maybe it could be replaced with public_methods => {...} section within implementation, and all the methods added there would automagically land in interface => []?

The documentation says nothing (or I did not read it carefully enough to find it) about how Minions behaves when stuff goes wrong. On the other hand, the fact that you provide code examples wrapped in simple tests, is wonderful. More examples should be written this way.

Looking forward to future updates. Best luck with your distribution.

- Luke


In reply to Re: RFC: automating modular classes by blindluke
in thread RFC: automating modular classes by Arunbear

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.