SPUG: Scope question
Andrew Sweger
andrew at sweger.net
Wed Jun 12 14:44:41 CDT 2002
On Tue, 11 Jun 2002, Colin Meyer wrote:
> I am in full agreement with Jason's comment about passing parameters
> around explicitly. In fact, I read a corny quote from _Code Complete_ at
> last month's SPUG meeting to that effect, about parameters being a kiss
> on the lips between routines (who's goal is strong cohesion via loose
> coupling - or something like that ;-). That is, it gives me a headache
> to search around for the meaning of a global variable, when I find it
> randomly accessed from deep within some routine of some module.
Amen, brother.
> However, there are perfecty valid uses for global variables. In a module
> that is used for manipulating data in a relational database, how tired
> do you get of passing around the database handle into each routine, or
> accessing it from buried within your object. Just put it in a global,
> document that to be your API, and use it when needed. Another fine use
> of a global is to hold application configuration data.
Go ahead an thump me on the noggin fer sayin' it, but I prefer a lexical
variable scoped to the module's file (or in a closure). Same thing, but
different, no?
--
Andrew B. Sweger -- The great thing about multitasking is that several
things can go wrong at once.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list