Having one and only one piece of data that is shared by many modules is rarely a problem. In effect, that one-and-only-one is functioning as an "application object". However, most programs of any real size don't stay that way.

The thing to watch out for is when you find multiple bits of data are always being passed together to functions. When that starts happening you need to encapsulate the things that get passed around together into a single object. Then instead of passing several parameters and having to remember what order you usually use to pass them, you can pass one single parameter that gives access to all the other information.

The other thing to watch out for is things that change together. If setting one variable causes ripple effects in other variables, the thing that changes and all the variables affected by it should normally be encapsulated into a single object. Sometimes you may find that A triggers changes in B1,B2,B3 and B3 triggers changes in X,Y,Z. In that case you may need two objects:

Best, beth


In reply to Re: How to write effective modules by ELISHEVA
in thread How to write effective modules by salazar

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.