Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
A few questions I like to ask myself when deciding on the split between procedural and OO
  • how many classes am I likely to write - if it is < 3 perhaps procedural is better
  • are there obvious inheritance relationships - '... and this report is just like that one, except that it doesn't have a totals section' - if there are, OO seems a stronger approach
  • what are the odds of the original code needing several changes/additions in future - would small objects help make these changes easier to introduce
  • would an object acting out a pattern of behaviour make the code easier to use/develop - e.g. I like to model processing record-based files with an iterator like pattern
    while (defined (my $record = $file_object->next()) { # next creates a +record object from data in the file $records->process(); }
  • do I need flexibility in applying my objects ? Will this be easier/clearer in OO or procedural ? e.g.
    # OO $object->fold()->spindle()->mutilate(); #procedural my $rc = mutilate(spindle(fold($data)));
  • if you have the knowledge - are patterns (ala GoF) going to help - these well-known solutions generally seem better in OO contexts, but that is not always so
  • how many methods will these classes have - perhaps lots of single function objects would be better as a library of functions - unless these classes are overriding specific portions of a parent class (specialising their interface)

there are no hard-and-fast rules - except that the more experience and knowledge you have, the better your decisions will be. So, in the beginning, you can expect to make bad decisions - but as long as you view them as learning examples, then making them can be seen as encouraging.

In reply to Re: perl OO - to use or not to use by leriksen
in thread perl OO - to use or not to use by kiat

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 goofing around in the Monastery: (3)
As of 2024-03-19 05:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found