Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #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":



  • 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 exploiting the Monastery: (4)
    As of 2014-09-20 00:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (151 votes), past polls