1

I am completely new to this and am following a tutorial on msdn: http://msdn.microsoft.com/en-us/library/aa645736(v=vs.71).aspx#vcwlkcominteroppart1cclienttutorialanchor2

My question is why do we use COM Interfaces AND COM CoClasses? It seems odd to instantiate an instance of a COM CoClass, instantiate a new object that is the old object but casted as the COM Interface.

I really am just wanting to grasp the ideology here...any help is useful.

2 Answers 2

3

The theory is to seprate the interface (what an object can do) from the implementation (how it does it or more specifically what specific code is instantiated to do it).

Defining types only as interfaces allows COM to specifiy how objects across multiple languages inter-operate; this being one of its main goals. Since the interface specification is a contract for how to pass data and invoke methods any language can expose a COM object without clients needing to know about the inner workings of the implementor (the CoClass).

This allows VB6, .net, C++, deplhi and any number of other languages to interoperate within the same application.

The wikipedia article on COM has some good background in this regard.

Sign up to request clarification or add additional context in comments.

Comments

1

This is a basic design principle in software engineering, interface is a contract, in com world, coClass is a implementation. for COM, the interface can be defined in IDL, but implementation (coClass) can be done in VB, C++, .net etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.