As for the invocants being in in different classes, that is indeed what I suggested. Like LWP does with the LWP::Protocol::* classes. This solution has pros and cons, with the need for appropriate classes to exist being one of the cons. But if we're going to rule out a design technique because it requires us to create a few extra classes, then we would never use MVC. Sometimes it is not worth adding classes, but if it makes sense, don't hesitate.

Speaking of MVC, Dan Sugalski's prolems seems to me to be one that you can solve with an MVC design. In fact people happily do so in languages like Smalltalk and Ruby. Yes, it does mean designs with some extra redispatching. I don't consider that a major flaw.

As for your Some::Parser example, I grant that a direct class-based dispatch doesn't work there. However it is trivial to extend it in ways where a direct MMD dispatch won't work either. For instance suppose that you're parsing any of several related formats and need custom logic to autodetect which format you've been presented with. If you're getting that specialized, it makes sense to me to have customized dispatch logic. Not every facility needs to be built into the language, and people have been writing parsers with customizable behaviour since before either of us started programming.

I agree with you about interfaces being more important than types and classes. And that's one of the reasons that I have no problem writing small helper classes whose job is to do the translation so that different kinds of things can present the interface that you want.

And I should point out that you did use the getter/setter example. I direct you to your implementation of name in The beauty of MMD.


In reply to Re^3: The beauty of MMD by tilly
in thread Perl 5's greatest limitation is...? by BrowserUk

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.