[AccessD] Global Variable

DWUTKA at marlow.com DWUTKA at marlow.com
Tue May 17 13:47:50 CDT 2005


Okay, so if you are into these habits, why would Globals be bad practice?
Wouldn't a gbl prefix alert you that you are using a variable with Global
scope?  You're post is a contradiction.  You have these habits, but you are
your own ghost writer?  Why?  The purpose of good habits is to prevent bad
things from happening.

Honestly, I do differ on Global variable prefixes.  I use a prefix custom to
the application. (Usually a three or four letter prefix, as long as it
doesn't clash with something.  ie, if I was writing a 'Table Maker' system,
I wouldn't use tbl (or even tblm...that would be confusing), instead I would
prefix Globals (if I needed them) with tmkr or maybe tbmk.  They would ALL
be in one module, all by themselves...modGlobalVariables.  Using the tmkr as
a prefix in this instance has several advantages.  Let's say I develop a few
classes and modules that perform a specific purpose.  Now I want that
purpose in another project.  I can truly move that code to the new project
with no fear of clashing the globals, because they will be prefixed
different.  In most cases, i will even keep the prefix for the new project,
and just comment that it came from another one.

Drew

-----Original Message-----
From: John W. Colby [mailto:jwcolby at colbyconsulting.com]
Sent: Tuesday, May 17, 2005 12:29 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Global Variable


Gustav,

Believe me, I AM my own ghost writer on many occasion.  Sometimes we just do
things because it is the right way to do things.  I have found that I can do
things by habit or I can "have to think about doing things".  

One of the things I learned to do "by habit" long ago was always use a case
else.  If you expect 10 difference cases, then specify those cases, but USE
AN ELSE where you place an error message.  If it falls into the else, then
you didn't expect it and you will be notified that your code is doing
unexpected things.  To some of our esteemed associates that might seem like
wasted keystrokes, but if you are notified automatically you can save hours
of head scratching when some bizarro case buried in the bowels of your code
happens unexpectedly.

I dim my variables with a naming convention by habit.  The habit was a
little difficult to start using but after that it just fell into place and
it always happens.  I use variable scope as a programming habit.  There is
still a millisecond "thought process" to figure out the scope, or the naming
prefix, but the actual "doing of it" is automatic.  

My personal opinion is that if I am going to use any convention, then the
"doing of it" has to be habit, or it is sporadic and in the end not very
useful.

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, May 17, 2005 1:06 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Global Variable


Hi John

I see your point, just wondering who are these "anyone"? 
No ghostwriters are writing to my globals.

/gustav

>>> jwcolby at colbyconsulting.com 05/17 6:19 pm >>>

>If you are not saying that they 'go away' as an argument, why do you
consider them 'bad practice' still?

Because anyone anywhere can overwrite them.  ..
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list