COM Library

Component Versioning

As more functionality is introduced to various components, a versioning mechanism must be in place to update older versions of components . A fundamental strength of COM is its support for versioning and component evolution. At times, it may be necessary to change the functionality of server objects without changing the clients of the object. With COM, objects and services can easily continue to support the interfaces through which they communicated with older clients , even while they provide new and better interfaces through which they communicate with newer clients.

Support for Components

COM solves the versioning problems inherent with the evolution of components. Existing clients are not rendered incompatible as server objects change. In other words, COM defines a system in which components continue to support the interfaces through which they provided services to older clients, even as they support new and better interfaces through which they provide services to newer clients. At run time, old and new clients can safely coexist with a given COM component. Errors can only occur, and can be handled easily, at bind time or during a QueryInterface call. There is no chance for failures, such as those that occur when an expected method on an object simply does not exist, or when its parameters have changed.

Backward Compatibility

For example, Visual Basic maintains backward compatibility by preserving class ID and interface ID information from previous versions of your component. If you make a new version of your component using the Binary Compatibility option in Visual Basic, the new version of the component will still work with older clients. New client applications compiled using the new version of your component can make use of the enhancements, because they compile in the new class IDs and interface IDs. As long as you preserve binary compatibility, late-bound clients will continue to work with your component.

Adding New Interfaces

When you update a software module, you are generally adding new functionality or improving on existing functionality. You add new functionality to a COM component by adding support for new interfaces. Because the existing interfaces do not change, other components that rely on those interfaces continue to work. Newer components can use the newly exposed interfaces.

Because the QueryInterface method of the IUnknown interface is invoked when using early binding, the current capabilities of a COM component can be efficiently evaluated each time the component is used. When new features become available, applications that utilize them will begin to do so immediately.

Versioning Mechanism

A good versioning mechanism allows one system component to be updated without requiring updates to all the other components in the system.

Applications can create instances of your classes using the CreateObject function and the programmatic ID, as shown here:

The CreateObject function looks up the class ID in the Windows registry and uses it to create the object. Thus, it will always create the most recent version of the object.

Example

 Dim X As Object Set X = CreateObject("MyComponent.MyObject") 


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net