[Tutor] Question about 'scopes'

ahimsa ahimsa@onetel.net.uk
Tue Mar 25 09:33:13 2003


On Tuesday 25 Mar 2003 2:13 pm, alan.gauld@bt.com wrote:

> > Since this would deviate from 'normal', under what kinds of
> > conditions might one want to declare a variable as a global
> > variable rather than local?
>
> As few as possible. Global variables are generally held to
> be a bad thing in software engineering. There are very few(none?)
> cases when you *must* use global variables, but occasionally
> they help keep the code less cluttered. Use them sparingly
> is the golden rule...

I can appreciate that, and since the exception you noted has a viable=20
alternative that doesn't break the golden rule, then I see no need to=20
challenge that.=20

<snip>

> Once you start using classes and OOP you will find that these
> provide an even better way of avoiding globals almost entirely.
> But I suspect you're not quite ready for OOP just yet.

Damn! What gave me away??? :-D
Hopefully soon, though!

Thanks a lot

A

--=20
News from a diiferent perspective:
http://www.scoop.co.nz
http://www.fromthewilderness.com
____________________________
Prevent digital monopoly:
http://www.againsttcpa.com