Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://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":



  • 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 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?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found