[AccessD] Framework Discussion - Classes - What are they?

John W. Colby jwcolby at colbyconsulting.com
Fri Mar 5 21:28:58 CST 2004


I intend to move them to M-M however M-M only publishes once every two
months.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Susan Harkins
Sent: Friday, March 05, 2004 9:04 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Framework Discussion - Classes - What are they?


JC -- I'd like to suggest that we move this series to MTM -- we can send a
link each time there's a new one and even run the text in the body of the
email as well. But that way, the information would be available longterm --
and via the newsletter links and not through just searching the archives.

Sound reasonable, good?

Of course, do as you like, but I think having these on MTM would be a good
thing.

Susan H.

OK, so what is a class and why do we want to use them?

A class is a module in Visual basic, but they are a special type of module.
Classes are used to hold all of the code and data required to describe some
object, in other words implement the behaviors and properties of that
object.  What sets a class apart from any other module in Visual Basic is
that a class is loaded in it's entirety and may be loaded more than once.
In fact it will be loaded once for each instance of the object being
modeled.

It is useful to use the data normalization model when designing classes,
i.e. a table models an object and should to the best of our ability never
hold data about two or more different objects.  Likewise classes should
model a single object and we should avoid having a class hold data or
implement behaviors of two or more different objects.  You might have a
"Bank" class, but that bank class should then use classes for the banking
objects such as accounts, customers, checks, deposits and so forth.  A
single class that tries to describe the bank and accounts and customers and
... is bound to be a mess.

So, if a class describes a piece of fruit it may have properties for color,
size, shape, weight, flavor etc. Until it is loaded a class can describe any
piece of fruit that matches or can be described using the properties
available in the class.  It really doesn't describe anything however until
it is loaded and these properties are filled with data, at which time a
specific piece of fruit is described.  This apple is red, is 3.5 inches in
circumference, is round etc.  That class instance then describes one
specific piece of fruit.  If you have a basket of apples and you need to
manipulate them using classes, you will load a new instance for every apple
in the basket.  If you have a basket of mixed fruit, you load two instances
that describe apples, an instance for a banana and an instance for each of
three pears.

A class is generally loaded multiple times specifically to describe multiple
instances of some object.  However this isn't a requirement.  A class may be
intended to only be loaded one time, but a class is still used by the
developer simply for the encapsulation it provides.  By putting all of the
code and variables in one place, a class can now be used as an object that
knows how to do something.  For example my framework has a framework class.
This class is only loaded once, it would serve no purpose to load it again.
However the class knows how to read setup SysVars out of a table to
configure itself, knows how to load other service classes such as an MD5
encryption class, knows how to count objects that the application is
loading.  So by building a single variable in a regular module, running a
function that sets that variable = to an instance of my class, and
initializing the class instance, a whole chain of events fires off loading
other classes, and setting my application up for business.  When I am done,
I can then call methods of my framework class which perform services for me;
zipping and unzipping files, encrypting and decrypting files, and in general
just acting as the application manager.

I am not yet writing a book on object oriented programming so in order to
keep these emails a reasonable size I am going to leave my explanation of
what a class is to the above.  Summarized, a class is a special type of
module which holds all of the code and data to describe or model the
properties and behaviors of one instance of an object, and which is loaded
one time for each instance of the object that we need to do something with.


John W. Colby
www.ColbyConsulting.com


--
_______________________________________________
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