Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2022-05-23 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?