At a high level the question is, "Should whatever this module represents be an object?" and the answer is often obvious from the context of its use. If the code to use the module will (or could) have more than one of the thing, then it should be an object and your module should represent a class.

At a low level the question is, "Does this code need to work with existing code which is already OO?". eg. if you are looking to extend/replace existing OO code then equally the answer should be yes.

You can always mix procedural and OO within one module if required/desired. And don't forget about functional either. Horses for courses.

Finally, if you still aren't sure which way to go, try writing your tests first (before the code which they will test). That may make the preferred paradigm clearer.


🦛


In reply to Re: Procedural vs OOP modules by hippo
in thread Procedural vs OOP 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.