[AccessD] Global Vars (was Ambiguous Name)

Drew Wutka DWUTKA at Marlow.com
Fri Sep 23 14:52:29 CDT 2011


Ah, but the 'fails in the field' issue is a TOTALLY separate issue.

A global variable will ONLY fail in the SAME way that a modular or
procedural variable will.  

Let's see, what are the 'fail' issues with global variables?

#1.  'A global variable can be changed from anywhere.... so it could get
a bad value'.  Really?  So let's look at a procedural variable:

Sub Main()
Dim x as Long
X=1+5
X=0
Msgbox 10/x
End Sub

Holy Division by Zero Batman.  We just 'broke' a procedural variable!
Darn it, no more using those!!!  We could also try to set X="Hello",
again, fail.  A variable is a representation of something, whether it is
an object, or a value.  If we do not know how to handle that
representation, it isn't a matter of scope, it's a matter of technique.

#2. 'Ambiguous Name'....  Ok, this should really be a no
brainer....ummmmm Naming Convetions?

#3. A hard stop will clear a Global Variable's value......

	- Ok, first, this only applies to VBA, not VB or .Net.  Stopping
the code in those platforms ends the program.  
	-Next, it also clears the values of modular and procedural
variables.  

Drew



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kenneth
Ismert
Sent: Thursday, September 22, 2011 5:40 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Global Vars (was Ambiguous Name)

> Drew Wutka:
> ...
> So, even if you wrap your global variables inside of a class, you are 
> still scoping an instance of that class globally, which makes it a 
> global variable...

My point exactly. The 'globals are bad' camp haven't explained how a
code wrapper that lets you change the value makes the global problem go
away.

And yes, there are common situations in Access where you want changeable
global values.

The only advantage I see to the wrapper is that you get to set a
breakpoint.
Little help when it fails in the field.

-Ken
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
The information contained in this transmission is intended only for the person or entity 
to which it is addressed and may contain II-VI Proprietary and/or II-VI Business 
Sensitive material. If you are not the intended recipient, please contact the sender 
immediately and destroy the material in its entirety, whether electronic or hard copy. 
You are notified that any review, retransmission, copying, disclosure, dissemination, 
or other use of, or taking of any action in reliance upon this information by persons 
or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list