If I have to call the get_handle() when I need it, I can appreciate that there's a performance cost. But pulling this handle through numerous calls to subs that don't need the handle themself, with the only reason to provide the handle to a 'sub-sub' feels as paying for something without getting anything in return.

Furthermore, imagine three subs named x(), y() and z(). sub x() calls sub y() that calls sub z().

One day sub z() is changed and needs access to the handle. As a result, the programmer must change sub x() and sub y() to take the handle as a parameter even though they couldn't care less about the handle themself.

This would lead to discussions like: "If we want to change sub z() to use the functionality of Module.pm, then we must first do an impact analyze to determine how many other subs must be enhanced to provide the handle, directly or indirectly, to our sub z()".

If sub z() can get a direct access to the handle, the change can be implemented in sub z() with no impact on other subs.

Yes, I'm talking about rather big and complex Perl applications here.


Everything went worng, just as foreseen.


In reply to Re: Re: Avoiding global object handle by Biker
in thread Avoiding global object handle by Biker

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.