I run into a similar question. I use a hash to store variables used by a group of subroutines, and pass around a pointer to the hash instead of using argument lists. I create modules, so that the subroutines using this pointer are in a module.

My training (from Conway) tells me that this is object-oriented code. The question I run into is, "When should I bless a hash pointer to make Real Perl OOTM code?"

My answer is, "As soon as the API that I want to create benefits from it."

It's all about the interface. I imagine that my subroutine calls look good, and are nicely documented with POD. The synopsis section of the POD is a working program that easily solves a real problem. The calls are easy-to-read and self-documenting.

The bless statement makes it possible to create a better API under some circumstances. If I'm not going to make a good API, I don't bother with the trappings of OO.

If I can imagine a good API, then it is worthwhile to fulfill my vision and implement it with the tools that are available. When I write this code, I often need a bless statement.

Without the vision of a good API, the rules of thumb for "when to use OO" do not inspire me enough to bless my objects. I save my blessings for objects that I want to be proud of!

It should work perfectly the first time! - toma

In reply to Re: When are packages the right design choice? by toma
in thread When are packages the right design choice? by fuzzyping

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.