Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Component Object Model (COM)? Is it language-dependent?

Tags:

.net

com

I'm new to COM, and I don't know what it is or why it exists.

Is this a programming methodology like OOP? Do programming languages have to support it? (with some special keywords or something)

When I asked my professor about it, he said:

COM is a binary-stable way to do OOP. We need to know binary-layout (something..something..)

I've no idea what it means. Some people say it is used for code reuse. OOP does a good job at that already, so then why did this COM evolve in the first place?

What is it with C++ and COM? Wherever I see COM, it's is always described with abstract C++ examples. Is it only for C++?

Can any one show me a case or exmaple so that I can understand the need for COM? What are the requirements for learning this, so I can write my own components?

like image 311
claws Avatar asked Oct 29 '09 18:10

claws


People also ask

What is Component Object Model (COM)?

Component Object Model (COM) is a simple Microsoft specification method that defines a binary standard for exchanging code between two systems, regardless of the OS or programming language. COM provides access to distributed client object services and is used to share cross-platform binary code and programming languages.

What is COM component in C++?

Component Object Model. Component Object Model (COM) is a binary-interface standard for software components introduced by Microsoft in 1993. It is used to enable inter-process communication object creation in a large range of programming languages.

Can COM objects be used with any programming language?

For some applications, COM has been replaced at least to some extent by the Microsoft .NET framework, and support for Web Services through the Windows Communication Foundation (WCF). However, COM objects can be used with all .NET languages through .NET COM Interop.

What is a COM object?

Rather, COM specifies an object model and programming requirements that enable COM objects (also called COM components, or sometimes simply objects) to interact with other objects. These objects can be within a single process, in other processes, and can even be on remote computers.


2 Answers

COM at its core is a way of providing a data-passing contract which is independent of any specific language. It is provably not language dependent, as there are many languages which support COM (there are C++, C, .NET, and Java implementations)

In practice it is useful for a couple of different examples:

  1. Communication between different languages: Because COM is language independent, it is possible to use COM to pass data between components in different languages. For instance you can use COM to talk between C++, Java, and .NET code.
  2. Threading Semantics: COM allows you to define threading semantics for a particular component to ensure it is created in the appropriate thread context no matter where it is used.
  3. General componentization.
like image 115
JaredPar Avatar answered Dec 16 '22 01:12

JaredPar


COM was first created as a mechanism to allow Microsoft Office applications to communicate with one another, then, in its second iteration it was modified and extended to become a specification for how binary code components could--if they were constructed according to the specification-- communicate with each other, and share data, no matter what language or OS they were built upon (as long as the binary file (the compiled .dll or .exe) conformed to the COM specification).

The purpose was to allow "binary reuse" which means that a code component could be reused by multiple client code components, that the original code component knew nothing about, and which were not even in existence when the component was originally compiled. To quote from one of the original architects of COM, Don Box:

[...] The design paradigm of COM was that component contracts are expressed as type definitions. This was a step forward from the world COM replaced, in which contracts were expressed only as simple functional entry points.In this respect, COM was a major advance because it brought the dynamic loading of code and the type system together in a fairly consistent manner.

like image 22
Charles Bretana Avatar answered Dec 16 '22 02:12

Charles Bretana