Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!mozo.cc.purdue.edu!wizard.pn.com!Germany.EU.net!howland.reston.ans.net!ix.netcom.com!netcom.com!jnedzel
From: jnedzel@netcom.com (Jared Nedzel)
Subject: Re: [ALL] Global Variables
Message-ID: <jnedzelDKM096.8qo@netcom.com>
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: <4cafr0$f2f@tst.hk.super.net> <johnson.820593081@sal> <4cdfki$84v@tst.hk.super.net>
Date: Wed, 3 Jan 1996 14:29:30 GMT
Lines: 41
Sender: jnedzel@netcom2.netcom.com

In article <4cdfki$84v@tst.hk.super.net> footprnt@news.hk.super.net (Mr footprint) writes:
[deleted]
>
>I agree. But one last point, which is more an observation than 
>anything else. It may infact be better to boldly declare 
>globals, rather than trying to camouflage ones poor designs behind
>class variables. If you provide set / get accessors for a class 
>variable, then is it not the same as a global?

I disagree.  By using a class variable, you are sure that the "global"
is only accessed or changed through the accessors methods.  This makes the
system easier to debug because you can quickly find out who is accessing
or changing that value (e.g., by using senders of...).  In addition,
because this global is only accessed via the accessors, if you decide
to change the implementation, you can probably do so without changing the
client clode -- instead you can just change the accessors.

Finally, using class variables can reduce your name-space usage.  For example,
suppose you have three global variables:  Foobar, Snafu, and Asap.  Now
you have three "reserved" words that can't be used anywhere else in the
app (provided you want to access these values).  Now, suppose you instead
created a class Global, with three class vars: Foobar, Snafu, and Asap.
Now, the only global identifier you've added is the class Global.


>Disclaimer: 
>I'm not advocating the use of globals, just alluding
>to the fact that class variables are not much better.

I disagree.  I think class variables give you more flexibility and reduce
your usage of the namespace.  You can also find the classes and the
class variables in the browser -- you can't find the globals as easily.




-- 
-------------------------------------------------------------------------
Jared Nedzel  					jnedzel@netcom.com
MRC Partners

Just because I'm paranoid doesn't mean there isn't someone out to get me
-------------------------------------------------------------------------
