Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Agree with your PS. A factory is the way you hide your implementation classes (quoth c2: "It allows classes to defer object creation to a separate method") from callers who just use that API to obtain the specific flavour they're wanting with something like Bod::Social->new_for( 'Twitter' ) rather than explicitly hardcoding creating an instance of a specific subtype. End users just know they're getting something that isa Bod::Social and can expect it to provide that same interface specialized for their particular kind of thing. You also don't have to go change callers to have them instead instantiate Bod::Social::NewTwitter n months hence when you create a new subclass which is faster or handles some new wrinkle; change the factory and callers get the improved version without knowing they have to ask for it.

Prossibly not germane in this particular case but if all of the different "flavors" vary only in how to implement some common behavior you might could use Strategy to implement that instead of having full subclasses for each network/type (although you might still want to use a factory method for instantiating the different strategy implementations).

Or it could just be too early and ENOCAFFEINE and I'm rambling . . .

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re^2: Designing multiple related modules by Fletch
in thread Designing multiple related modules by Bod

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.
  • 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?Last hourOther CB clients
    Other Users?
    Others musing on the Monastery: (5)
    As of 2025-06-19 09:24 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.