[AccessD] Class Rebuttal was: Basic Unbound Form ...

John W. Colby jwcolby at ColbyConsulting.com
Mon Jun 12 20:36:18 CDT 2006


Drew,

I do want to thank you for taking on this class / framework lecture.  I
think that this stuff is critical to truly mastering Access / VBA.  Just try
your best not to get sidetracked defending every little thing.  You have
bigger fish to fry here.

Drew/Stewart

>Huh?  So you either constantly read the ini file by creating a new instance
of the class, or you set the class as a global variable, and it only reads
it when it's first initiated.  Why reread the ini file over and over?

No actually you read it into a private variable and then use a public
function to serve it up to the project.  The class isn't REQUIRED.

Dim Private MyConnectString

Public function gCnnRead()
	.
	My Code which reads the connection string into the private variable
	.
End function

'
'A function to make the variable read-only (but global)
'
Public function gCnn() as string	
	gCnn = MyConnectString
End function

Publics tend to be "bad" because they can be stepped on intentionally (by
hackers) or unintentionally (by the programmer(s)).

By creating private variables and then accessing them with a function, you
get the functionality of a global (readable from anywhere) but you also get
the protection from being stepped on.  Unless of course you need a global
that can be written from various places in the program, and then you get
what you get.

In fact what I do is a private FRAMEWORK variable.

Private lclsFW as clsFramework

Public function FWInit()
	set lclsFW as new clsFramework
	lclsFW.Init(MyParams whatever they may be)
End function

Public function FWTerm()
	lclsFW.Term
	sel lclsFW = nothing
End function

Public function gFW() as clsFramework
	set gFW = lclsFW
End function


The framework then reads the connection string as part of the init, and
exposes the connection as a property (read only, property get)

	gFW.pCnn

Thus the framework variable itself is "global" (but readonly, cannot be
corrupted unintentionally) and the connection string is likewise global
(because it is a framework property and the framework is "global") and
likewise readonly so that it cannot be corrupted.



John W. Colby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of DWUTKA at marlow.com
Sent: Monday, June 12, 2006 8:30 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Class Rebuttal was: Basic Unbound Form ...

Huh?  So you either constantly read the ini file by creating a new instance
of the class, or you set the class as a global variable, and it only reads
it when it's first initiated.  Why reread the ini file over and over?

Drew





More information about the AccessD mailing list