3 ms·
The core of COM is simple, elegant, and definitely "reachable". Don Box's "Essential COM" is a great book on the topic that clears away all the cobwebs that you
by mypalmike 9y ago
The core of COM is simple, elegant, and definitely "reachable". Don Box's "Essential COM" is a great book on the topic that clears away all the cobwebs that you fear are there. The more advanced topics do indeed become a bit more complicated.
The core idea of COM is that you have objects that you solely interact with as a client by using interfaces. An interface is just a set of methods (under the hood, it's an array of function pointers, in the form of C++ vtables). An object can implement multiple interfaces.
So, for example, in the context of a videogame, you might have a player object that you can send joystick input to, you can render, and and you can persist to JSON. That object would have something like IInput, IRender, and IPersistence interfaces. If you have a reference to any of these interfaces, you can ask that interface for any of the other interfaces (QueryInterface).
At the heart of COM, that's really all there is to it. Method dispatch is as fast as C++ virtual functions because that's exactly what they are under the hood.
There are layers on top of COM which start to add complexity, particularly when you want interface/method discoverability. But you often don't need that, particularly when working with C/C++. I've worked with code (long ago) where just the core of COM was used, and it's really quite straightforward.