Page #34 (Error Reporting)


The Essence of COM

Breaking a monolithic binary file into separate software components that are linked dynamically at execution time gives us the ability to:

  • reuse a component from a third-party vendor

  • field-replace a defective component

To assure that the communication among the software components does not break:

  • the communication interface has to be separated from the implementation details.

  • the interface class has to be defined based on certain rules such that it provides a binary encapsulation.

  • the interacting applications have certain responsibilities in managing the lifetime of the object.

The whole architecture and supporting infrastructure for building and using component software in a robust manner is referred to as the Component Object Model or COM.

COM-based application development can be broken down into the following three steps:

  1. Define the interface: A software vendor or a group of vendors collectively declare the services they intend to provide by defining one or more interfaces. An interface is a semantically related set of methods grouped together. It defines an immutable contract at the binary level between a vendor and its clients.

  2. Implement the interface: A vendor that intends to provide the services of a specific interface implements the interface in its application. Such an application is called a COM server. Sometimes it is loosely referred to as a component.

  3. Use the interface: The application that intends to use the service via the interface is referred to as a COM client.

The server program that implements the interface has certain responsibilities such as maintaining the reference count, returning meaningful errors, and providing thread safety. We will examine thread-related issues in a later chapter.

The client program that uses the interface has other responsibilities such as appropriately adding or releasing references on the object, and examining the return status from every method call.

The interface definition rules that we have examined in this chapter achieved C++ compiler independence. Our ultimate goal is to achieve programming language independence as well as network transparency. The operating system has to be extended to support these goals. The developers have to be provided with some standard documentation and Application Programming Interfaces (APIs) when developing COM-based applications. These APIs appear in the form of the COM Software Development Kit (SDK), sometimes referred to as the COM library.

The rules and responsibilities of the client, the server, and the OS infrastructure are all documented by Microsoft in COM Specifications [COM-95]. The COM Specifications contain the standard APIs supported by the COM library, the standard suite of interfaces supported or used by software written in a COM environment, along with the network protocols used by COM in support of distributed computing. These specifications are still in draft form, and thus are subject to change.

COM is the most widely used component software model in the world. It provides the richest set of integrated services, the widest choice of easy-to-use tools, and the largest set of available applications. In addition, it provides a viable market for reusable, off-the-shelf, client and server components. Table 1.2 summarizes some advantages of COM by means of some comparative examples.

Table 1.2. Advantages of Component Model





A problem in the VCR requires the VCR to be replaced, not the TV.

A buggy component can be field-replaced without rebuilding the application.

Choice of vendor

Choice of any brand of VCR as long as it supports Video or S-Video output.

Component from any vendor that matches the specifications can be used.

Rapid application development

A complete entertainment system can be put together rather quickly using various components.

An application can be snapped together from various components.

Distributed computing

The VCR can be in the next room or in the next building.

A component can be located on a different machine.

Knowledge of component s internal workings not required

The technology used to build the VCR is irrelevant.

The C++ compiler used for the component is irrelevant. In fact, a component can be written in any programming language (as we will see in the next chapter).

Maximizing productivity

The TV vendor can focus on improving picture quality.

Application vendor can focus on what they do the best and the third party software vendors can focus on developing the best code.

In the chapters that will follow, we will take an in-depth look at the rules and responsibilities of developing COM servers and COM client applications. We will examine the APIs provided by the COM library and the role of the OS in facilitating the communication between various COM components.


COM+ Programming. A Practical Guide Using Visual C++ and ATL
COM+ Programming. A Practical Guide Using Visual C++ and ATL
ISBN: 130886742
Year: 2000
Pages: 129 © 2008-2017.
If you may any questions please contact us: