13.11. The Three Pillars

So far, you've examined how to create class modules that are complete with their own properties and procedures. You've seen how to develop their implementation code, instantiate them as objects, link them to other objects singly and in collections, and finally, use them in the application. For most cases, this is all you need to know.

But if you want to create a lot of related classes, and do it in the most efficient way, then you need to understand a few principles of object-oriented programming.

The three pillars of object-oriented theory are:

  • Encapsulation

  • Inheritance

  • Polymorphism

These things have different meanings to different people, and the extent to which they apply to an object-oriented language differs according to which language you happen to prefer. There are other factors like operation overloading, parameterized constructors, and class-level attributes, but their discussion is largely irrelevant because they are not implemented in Access 2007.

13.11.1. Encapsulation

A major advantage of object-oriented programming is the capability to encapsulate, or contain data and functionality within simple programmatic entities. That is, every instance of a class object contains exactly the same properties and methods as the class module it was based on. You've seen this in the classes you've created in this chapter.

Another way to describe encapsulation is data hiding. When you create a set of properties and methods to form a class's interface, external ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.