What is COM (Component Object Model)?

Asked

Viewed 515 times

8

I was reading this question1 here on the site and I have sometimes come across the term "objects WITH".

A brief survey showed me that WITH that is to say Component Object Model, but I couldn’t extract any more information than this.

What I’d like to know is:

  • What is an object WITH?

  • What use is this?

  • The relationship of COM is only with the graphical interface?


1 Difference between Stathread and Mtathread

1 answer

7


COM is the old . NET :P

For someone else maybe I explained it in another way, but for those who understand why . NET exists, that’s it. I’m talking about . NET, from CLI specifically, not from C#. But COM works with inter-process communication.

COM was the way Microsoft found for heterogeneous applications using various technologies to communicate without much knowledge of the details between them. The communication is made with strong contracts in the ABI and some very specific semantics. It guarantees a pattern for the exchange of objects (in a general sense, not in the sense of OOP, COM is not OOP although it gives some facilities to manage objects this way). It is not about API that is something specific to each application/component.

It is a beautiful of a gambiarra, but at the time seemed a good idea. It fulfills its role. Until today a lot of things in Windows can only communicate through COM. Even newer technologies from Microsoft use COM as a basis, for example UWP.

The . NET, of course, communicates with other external components through COM. Not everything needs to be by COM, but it has some advantages since it creates a minimal common denominator without requiring too much of the components and applications that are using it.

.NET talks well with everything that conforms with it, but not with other technologies. C++ has a very interesting model to talk to components written in C++, but not in other ways. And so it goes with most languages and platforms. COM brings it all together. He doesn’t care about memory models, Apis, code organization, any of this stuff. Of course it has a specification of how it should be used and any technology should conform to it. In theory any language can work well with it, from C to Javascript (yes JS accesses COM in certain implementations), going through Java, C#, C++, Pascal, PHP, Python, etc.

There are a number of specifics that I think don’t come to the point here. It’s quite complicated and boring to deal with.

The relationship of COM is only with the graphical interface?

It goes for any technology that wanted to conform to it. It is not exclusive to Microsoft and even less only to GUI.

Comparison

Some of his competitors are: CORBA, XPCOM, D-Bus, etc. Each with its own characteristics, advantages and disadvantages.

Not directly, but you can compare it to REST which is a way for applications to talk and exchange objects. Obviously very differently by the nature and objectives of the technologies.

  • "...in a general sense, not in the sense of OOP, COM is not OOP..." I disagree. WITH is OOP, even if you can do it using non-oop languages. It supports the basic principles of OOP, such as SRP, LSP, dependency inversion, messaging, everything as the costume says.

  • @Wtrmute yes, it’s even in a certain sense. But not in the general way people know OOP. One might think it’s an OOP language.

  • It’s because people have a crooked idea that it’s OOP. In any case, for COM to be an OOP language, it just needs to be a language. The same thing, of course, goes for the COM competitor, CORBA.

  • In fact, it has several ideas of what OOP is, and everyone thinks they have learned it is the right one. I’ve even answered something about it. To talk about OOP you have to know what the person has learned that is. And there are "documents" corroborating most of these ideas. Since I don’t know which one is the right one I pick one that makes more sense to me or that is more used and I go in it. The others I consider as something that should have another name because it causes confusion with what is understood in practice. In fact the COM just needs to be a language.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.