Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

  (email not shown publicly)
AOL IM: MichaelSchwern (Add Buddy, Send Message)

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Sunday April 17, 2005
06:17 PM

The Single Most Important Bit of Software Engineering Advice

[ #24248 ]

Make your globals and your locals look different.

I don't care if its $Global and $local or $GLOBAL or $GLOBAL{var} or $_local or whatever. Just make sure that when I'm reading an arbitrary hunk of your code I can tell what's global and what's not just be looking at the variable name. This is the single simplest way to avoid basic scope creep and its also the most often violated. I'm reworking some JavaScript code which as a handful of globals and they all have names like "current_image" or "state"... and so do the lexicals.

What's a global? Anything that exists across more than one subroutine. So yes, "file scoped lexicals" are global. What's local? Anything that exists in only one subroutine.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.