7.5 COMPONENT OBJECT MODEL
Different from the patterns discussed so far is component object model (COM) programming. Patterns are themes or genres of solutions that may apply to the programming challenge that we are faced with. They help us reuse our programming skills and experience in an efficient manner across multiple projects or challenges. Within one project, the object-oriented paradigm encourages and facilitates source code reusability. What is assumed in reusing source code is that we stick to one programming language. In large-scale projects, this assumption may turn out to be too much of a constraint. We may indeed want to use multiple languages to leverage on the strong suits of each of them to tackle different aspects of the problem at hand.
A component object model provides a means of sharing the code at the binary level, as opposed to the source code level that we are used to. It defines a set of binary standards on how COM objects must be structured in the computer memory. Once it is compiled in accordance with the standards, COM objects can be shared regardless of the programming language in use. The object memory structure closely mirrors C++, and for that reason we find most of the COM development in that language.
In COM programming, the consumer of the COM object (another developer) accesses it exclusively through its interfaces. Interfaces are abstract classes (with only pure virtual functions) providing the consumer with various functions. The code that implements ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access