Author: S S B Magesh Puvananthiran
The Advantages of using COM.
Answer:
Nowadays, COM is gaining popularity as most of the languages support development of
COM objects including Delphi. In future, all the activities of an Operating system
and applications would be services provided by COM. So the users can use those
services as easily as Plug-And-Play.
In this article, let me present you some of the advantages/attributes (but most of
them are attributes) of COM that I learned.
1. Object Oriented
All the COM objects are Object Oriented as its name implies. There are three basic
Object Oriented concepts:
Encapsulation: This is implemented by the interfaces provided by the COM Objects.
Those interfaces hide the implementation details from the end user and provides the
functionality to the user. By that, the user just needs to know what interface
methods to call, to do a specific operation provided by that COM object.
Polymorphism: This is often called “One Method Multiple Interfaces”. A COM object
could define a single method to perform a specific operation; but that operation
could be implemented through various interfaces/ways.
Inheritance: When we want to incorporate some additional functionalities to an
existing COM object, we can enhance the existing COM object by inheriting a new COM
object from it.
COM incorporates all those three concepts in it.
2. Loose Coupling
In a software, that uses COM objects, we can easily replace an existing COM object
with another COM object written in entirely another language as long as the
signatures of the methods in both the COM objects remain same. In that case, there
will not be any change in the existing software code that uses the COM object.
3. Easy Transition
Let us suppose that a software uses a specific COM object provided by a third
party. At some point of time, that third party might upgrade that COM object to
incorporate some additional functionalities. At this time, if we would like to use
the latest version of that COM object in our software, we can just remove the
existing (old) version of that COM object and place this new version of COM into
our software as long as the signatures of the methods in the old version of the COM
object do not change in the new version. But this is a standard for any COM objects
provided by third parties and for anybody who develops COM objects. If they upgrade
the existing version of COM object, they will not alter the existing signatures but
might add some optional parameters to those methods; But that will not affect the
existing system to function properly. So even if we develop a COM object and would
like to upgrade, then we should keep in mind the existing method signatures. At any
point of time the existing system should not get affected by upgrading to a newer
version of COM. This is rather a defined norm in developing COM objects. So
transition is easy.
4. Binary Language
Since most of the COM libraries are in binary language, it could be used by any
application written in any language. So COM is language neutral. This is one of the
main advantages of COM; it's language independent.
5. Resource utilization
Every COM object will be destroyed automatically as long as no client is using that
object actively. This is implemented by COM using a technique called reference
counting. Every COM object will maintain a reference count(the number of clients
using that COM object); Once that count reaches zero(that means no clients actively
using that COM object), then that COM object will be destroyed automatically. With
this approach, we can increase resource utilization in an application. Resources
such as memory will be best utilized by releasing the inactive/unused COM objects.
The above listing is just an overview of what COM offers us.
|