- Objects, Components, and COM
- Abstraction and Class Modeling
- Encapsulation
- Polymorphism
- Inheritance
- Association Relationships
- One-to-One Relationships
- One-To-Many Relationships
- Class and Object Naming Conventions
- Component-Based Development
- Component-Based Development and COM
- COM-Definable Entities
- Component Coupling
- Summary
COM-Definable Entities
A COM library not only enables us to define classes in terms of properties and methods, but also to define enumerations, events, and interfaces used in inheritance relationships. We already have talked about properties, methods, and interfaces, so let us complete the definition by talking about enumerations and events.
Figure 3.10 The remote, out-of-process invocation mode of COM.
Enumerations are nothing more than a list of named integral values, no different from global constants. What differentiates them is that they become a part of the COM component. In essence, the COM component predefines the constants needed by the application in the form of these enumerations. By bundling them with the classes that rely on them and giving them human-readable names, we can ensure a certain level of robustness and ease of code development throughout the overall application.
TIP
Use public enumerations in place of constants when they tie intrinsically to the operation of a class. This will keep you from having to redefine the constants for each application that uses the class, because they become part of the COM component itself. Where goes the class, so go its enumerations.
Events defined for a class are formal messages sent from an object instance to its application. The application can implement an event handler to respond to these messages in whatever manner deemed necessary.
NOTE
Visual Basic and COM define events as part of a class, alongside properties and methods. One might assume then that we can define events on an interface, thereby making them available to classes implementing the interface. Although this is a reasonable assumption and a desirable feature, Visual Basic and COM do not support this. As such, do not plan to use events in conjunction with interface implementation.