Chicago Access Users Group (CAUG) talk - "Class Modules in Access"

January 22, 2009

Kevin Anderson, Anderson Information Technology, Inc.

 

Goal = improve software quality (McConnell 1993):

·         Correctness

·         Usability

·         Efficiency

·         Reliability

·         Integrity

·         Adaptability (extensibility)

·         Accuracy

·         Robustness

·         Maintainability

·         Flexibility

·         Portability

·         Reusability

·         Readability (understandability)

·         Testability

 

Advantages of using classes/objects:

·         let's you create more complex objects than tables or queries provide alone

·         using classes within classes let's you restrict function visibility

·         class methods & attributes are more descriptive than module's function list alone

·         let's you use Intellisense for more efficient coding

·         no "ambiguous name" errors with multiple copies of the same class module

·         can copy class modules without worry of creating ambiguous function names

·         static variables are implicit in class objects, and so are easier to manage

·         isolating access layers within wrapper classes promote portability/maintainability

·         better support for separation of UI/business logic/data access = n-tier development

·         promotes modular thinking in analysis, design

·         easier to adapt many publicly-available object models to Access apps

·         prepares you for transition to .NET and other fully object-oriented architectures

 

Disadvantages:

·         can be more up-front work

·         encapsulation of data access subverts Access's built-in database mechanisms (e.g. locking)

·         can't call directly from macros, SQL; can't bind forms, etc. to classes/objects

·         limited due to no true inheritance

·         not available in Sharepoint Access databases (not likely to change owing to insecurity of VBA)

 

Links:

Example class add VB-like features to Access97 listbox: http://www.fmsinc.com/tpapers/97classes/index.html

Good collection like classes, like cStopWatch.cls: http://www.thevbzone.com

Access MVPs' code libraries, with some good uses of classes: http://www.rogersaccesslibrary.com/forum/forum_topics.asp?FID=3

Wrapper for image control: http://www.mvps.org/access/downloads/ImageClassVer11.zip

Calling a .NET Component from a COM Component (i.e. Access): http://msdn.microsoft.com/en-us/library/ms973802.aspx

Steve McConnell's "Code Complete, 2nd Edition": http://www.cc2e.com/

 

Informative discussion threads:

·         "Faking inheritance in VBA to remove code duplication"

·         "Try #2 - Inheritance work-around in VBA"

·         "Good book on using Class objects in Access?"