COM and UML

Home ] Up ] Glattetre ] www.trinidad-tobago.net ]

 

 

 

 

COM and ActiveX™ notation in UML and some basic principles

COM stands for Microsoft Component Object model. This model is a proprietary way of designing components and the way these components communicate. This is a competing standard to CORBA from OMG. The basic building block for this model is the COM object. A COM object is an object that follows certain rules. All COM objects must implement an interface called IUnknown. An ActiveX™ object is a COM object that has implemented the IUnknown interface, and knows how to register1 itself.

Figure 1Circle: Symbol accociated with an Interface

The symbol for an interface is a circle. In UML, this is a stereotype of a class.

Figure 2UML's notation of IUnknown displayed as a class

All interfaces in COM inherits from IUnknown. IUnknown has three methods:

AddRef   All COM objects has a reference counter. When the object is created, the reference counter is set to 1. Everyone using the object increases the reference counter when they start using the object, and they decrease the reference counter when they stop using it. When the reference counter is 0, the COM object destroys itself. AddRef increases the reference counter.
Release   Release releases the reference counter.
QueryInterface   QueryInterface has to arguments: a unique identifier of an interface, and a pointer to pointer to a place where a pointer to the interface can be stored. QueryInterface checks if the object has implemented an interface with the given unique identifier. If one such interface exists, a reference to it is placed in the supplied pointer, and the reference count is increased.

Figure 3Lollypop: The notation of an Interface that is implemented by an object

The symbol for an interface that is implemented by an object is a lollypop. The line between the circle and the object itself is, in UML, an association of type refinement2.

Figure 4Microsoft’s notation for a COM/ActiveX™ object.

A rectangle with rounded corners with the attached lollypop on the top is in Microsoft notation a COM object or ActiveX™ object.

Figure 5UML’s notation for a COM/ActiveX™ object.

A folder, or package, is the symbol of a group of something in UML. If an interface is associated with it, using the refinement association, it describes a package of classes that exposes an interface. This can be interpreted as an COM or ActiveX™ object.

Figure 6 Microsoft’s notation for aggregation.

Aggregation, the COM meaning of the word, means to expose another object’s interfaces out of your object.

The inner object uses the IUnknown implemented by the outer object for the IUnknown methods, hence reference counting and QueryInterface on the interface implemented by the inner object is done by IUnknown on the outer object, "Outer Unknown".

The outer object is responsible for creating the inner object, and it is responsible for releasing the inner object when its’ lifetime is over. It uses the IUnknown implemented by the inner object, "Inner Unknown", for this purpose.

Figure 7UML’s notation for exposing another objects interface.

The term aggregation has a somewhat different meaning in UML. However, it can be displayed in a similar way

Figure 8UML's notation for exposing an interface.

All this can be simplified, by only showing the outer object, and displaying the interfaces exposed by it. For all objects using this object, it is of no concern whether the outer object implements the interfaces, or if it is some aggregation is used in order to achieve additional functionality.

 


1 Registration is a subject that will not be discussed in this document. Look at the reference for regsvr32.exe in the Microsoft documentation for further information.

2 For further reference on refinement, look at the latest UML documentation, or ask Grady Booch.

 

COM and UML
File Streaming
ASP.NET Hello World

Please visit trinidad-tobago.net