Containment Delegation  «Prev 

COM interfaces are Immutable

Interface is not allowed to change

The phrase "COM interfaces are immutable" means that once a COM interface is published or deployed, its specification is not allowed to change. This applies even if different COM objects implement that interface.
For example, once interface IX1 is published or deployed, all COM objects that implement IX1 must implement the interface exactly as specified. So if IX1 has the following IDL (interface definition language) definition:

[object,uuid(...)]
interface IX1 : IUnknown
{
   HRESULT x1(int ix);
   HRESULT x2();
}

All COM objects that implement IX1 must implement x1 and x2 in vtable[1] order with the specified parameters.
This does not mean that IX1 will have the same implementation in different COM objects. It means only that the vtable ordering and method parameters remain the same.
Consider the case of IUnknown. All COM objects implement QueryInterface, AddRef, and Release in vtable order with exactly the same parameters. However, a call to QueryInterface in one object can have a different implementation than a call to QueryInterface in another object because the objects probably support different interfaces.

Interface

An interface is a set of method prototypes. To utilize a method of an interface, a client should get a pointer to the interface. This pointer, if available, is returned by QueryInterface upon request by a client. Every component is required to have an IUnknown interface. A client program, which has requested the system to instantiate a component, will have a pointer to the component. Using this pointer and the QueryInterface method of the IUnknown interface, a client can get a pointer to any interface available from the component. Calling the QueryInterface method asking for an interface is called interface negotiation. Interface negotiation is reflexive, symmetric, and transitive, which is also known as an equivalence relation in discrete mathematics.
[1]vtable aka virtual table: For every class that contains virtual functions, the compiler constructs a virtual table, vtable. The vtable contains an entry for each virtual function accessible by the class and stores a pointer to its definition. Only the most specific function definition callable by the class is stored in the vtable.