OOP is not a solution for all problems, nor is shunning it and using functional programming a solution for all. Sure, nearly every problem can be solved in both, but one may be easier than the other to write the code for, or it may be equally easy.

The way I look at it, think of your problem and try to work out if object patterns fall out of it immediately. Things like business transactions, GUI elements, and the like will naturally be suited for OOP, while more rigorous low level tasks like network communications, file manipulation, and the like, are best done in "step a, then step b, then step c...". If you cannot easily recognize a good object structure within a few well-spent minutes of thinking on it, then it's probably better to avoid using Objects all together and stick to functional programming.

This is not to say that after you've gotten the meat of your functional program in place, you cannot provide an Object (which could be as simple as a Module) that can be used to wrap these functions in an object framework. From some that I've seen, a good number of CPAN modules are of this type, where you have a few module-level functions that do a task and include some properties setting, but there's a lot more hidden away behind the scenes, thus acting like a true OOP object.

update typo fixed


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

In reply to Re: Hacking with objects by Masem
in thread Hacking with objects by frankus

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.