Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
The way I remember it, locals versus globals and a heap of other ideas more or less came into being along with the 'Structured' revolution. If you want a good (possibly best) introduction to some of the pre-object ideas, you can't do much better than Structured Design by by Ed Yourdon and Larry Constantine (Prentice Hall/Yourdon Press, 1978.) And for an honest and funny appraisal see Ed Yourdon's self-review.

More current thinking (i.e. oo) would say that variable scoping is tied to the idea of information hiding. In a kind of paranoid fashion, the goal is two (at least 2) fold, first, don't let anyone see object information that they have no 'need to know' clearance for. Second if they really, really, really must muck with your stuff, at least insulate that with the usual get/set pair (publish through a controlled interface.) More to the point, globals violate the hell out of these ideas—hence the bad reputation! On a real world basis, you can obviously do whatever you want, but it is usually better practice to avoid global scope, only using them when there is a clear need for same. My usual excuse comes from code optimization, stuffing a variable on the stack when I need to call a function, takes time so if time is crucial I make the needed stuff global. I'd point out here that if speed is a concern, you most likely wouldn't be using Perl anyway, more like assembler or C!

hsm


In reply to Re: best practice by hsmyers
in thread best practice by George_Sherston

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2014-07-31 05:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (245 votes), past polls