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

Comment on

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

Long time listener, first time caller: be gentle.

I've seen the topic of OOP/inheritence covered here more than a few times. I wade through the Camel and Damian books an a seemingly daily basis.

While most of it makes several degrees of sense to me, I keep wanting more in terms of creating OOP modules in a plugin-style of development (my apologies for forgetting the _type_ of inheritance this is at the moment).

For example, let's say I'm working on a shopping cart module. It has the usual methods: add, remove, empty, save, etc.

Now I want to make this module flexible as possible by creating different I/O schemes underneath so the cart contents could be stored in LDAP, FTP, File, Hash, Session, DBI, etc.

This is where I get lost. I know theres more than a few ways to go about this, but what are the best ways to do it? I understand the side of OOP which I can extend the module to include a myfoo method, or override the add method. But I can seem to grasp how to ensure that the base module ALWAYS has the expected methods _and_ parameters and only the implementation changes.

I think If I could find some examples of this stuff, I'd be ok. (In my head at least) Most of the OOP examples I see are based on extending a base class by adding functions to it. It seems very few examples cover the other end of the fence: creating I/O filters/interfaces to parent classes.

The methods I've seen range from passing the I/O module name as a parameter or via %ENV to using the I/O modules directly and interweaving public/private methods.

Disclaimer: I did come from the *cough* windows *cough* side of OOP, where there are interfaces in COM that are 'implemented' by the I/O modules or plugins, so if an object implemented an interface, you were assured that it accepted the methods/parameters required. This is probably why I'm having a hard time wrapping my brain around this in Perl OOP.


In reply to OOP: Plugin Style Development by jk2addict

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (7)
    As of 2014-04-21 08:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (492 votes), past polls