Component Object Model, abbreviated as COM, is Microsoft's framework for developing and supporting component objects. It enables interprocess communication and dynamic object creation. Let us obtain a deeper understanding of the same.
Understanding the COM Technology
Prior to development of the Component Object Model, one of the very first methods of interprocess communication was Dynamic Data Exchange (DDE). It enabled communication between computer applications and was based on the concept of Object Linking and Embedding (OLE). Around the time of the release of Windows 3.1, COM was created. Microsoft came up with the COM framework in 1993. DCOM that allows the interaction between distributed objects was introduced into the Component Object Model only in 1996.
When programers build COM-aware components, each component is identified by a class id. Each component functions through an interface. Each of the interfaces is identified by an interface id. Interface methods are used to access the COM components.
All the COM components are required to implement the IUnknown interface, from which all the COM interfaces are derived. The IUknown interface has three methods, namely, AddRef(), Release(), and QueryInterface(). The methods AddRef() and Release() implement reference counting and determine the lifetime of the interfaces. The QueryInterface() method allows retrieval of the interfaces which the COM implements. The COM component's interfaces should be transitive, reflexive, and symmetric. COM interfaces contain a pointer to a virtual function table. Wondering what a virtual function table is? It is a table that contains a list of pointers to the functions implementing the functions that are declared in the interface. I know, it sounds confusing. But rereading the statement might help.
COM classes, known as Coclasses can either be groups of similar objects or representations of object types. A COM coclass gives a concrete implementation of one or more interfaces. For COM objects to be instantiated, they require an associated class id and an accompanying class factory. Class factory is a COM object, which is responsible for the creation of other objects. It can be imagined as a factory that manufactures objects based on the class id of the class whose objects are to be created.
COM makes use of type libraries, so that COM types can be accessed at both compile time and runtime. COM can serve as a dynamic framework owing to its efficient use of type libraries. Type libraries contain the metadata, which represents COM types. COM types are written using Microsoft's Interface Definition Language, a text-based language compiled by the MIDL compiler.
COM is a runtime framework that allows the development and deployment of object-oriented components. The primary advantage of the Component Object Model is that it is founded on the object-oriented principles. It has given rise to the development of popular technologies like COM+ and the .NET framework. COM+ provides the users with support for distributed transactions. The .NET framework has taken over the COM platform and is largely being used for software development. Moreover, it supports a language-neutral object implementation. COM technology is perhaps the most suitable means of developing and deploying desktop applications. It can be best described as an infrastructure that allows building speedy, robust, and extensible component-based software.