What Is Com: Component
What Is Com: Component
COM stands for Component Object Model. It is a Microsoft specification that describes how to create reusable objects for programmers working in a Win32 programming environment. This makes it easy to develop objects that can be distributed independently of an application program file. In earlier versions of VB or other windows programming environment, the COM under other names such as OLE Server or Activex Server.
Component:
It is an independent piece of code that may be shared with several different programs.
Object:
Object is a set of code that is designed to be reusable with a well defined interface. COM is based on Client-Server Model ,each COM object operates s a Server that receives and processes requests from a client program and generates responses
Requests Response
Property:
A Property represents variable in your objects, although its often implemented as a pair of routines: One to retrieve the value form the property and another to assign a value to the property.
Method:
Method is merely a function or subroutine that can be called from a client program.
Event:
An event is a subroutine whose parameters are defined in the control and that exists in the client program. It is called by the control to inform programs of various situations.
NECESSICITY OF COM
Components and Objects are used to develop an application. Since many languages have the ability to include objects in source code, why should you use COM? COM is the foundation of most things that Microsoft does. Without COM ,Visual Basic wouldnt work, nor would Windows, SQL Server, or any number of Microsoft products. The true test of Microsofts confidence in COM is that its applications are based on COM technology. Word 2000 and Excel 2000 are based heavily on COM, as are many other Microsoft applications. When you build multiple program using objects, the objects are compiled into the object code. This has a couple of disadvantages:
If you have multiple programs, each executable program has its own copy of the objects. This means that any time you change the objects, you must recompile all of the programs that use them.
You must use the same programming language that the objects were written in to create your application programs. This restricts your choice of programming languages.
Since COM Objects are stored in their own independent object file, you can change the object without recompiling the applications that use it. You can also add new interface to the COM objects to offer new features and capabilities.
DDE:
In early days of Windows , people used a clipboard much like they do today. Users could copy parts of a document in program on to the clipboard and paste them into a document in another program. However, when dealing with complex graphical documents, users found that a simple clipboard didnt work very well. In late 1980s Microsoft developed a technology called DDE to allow programmers to simplify the process of sharing the data using a clipboard. This technology was available for only Microsoft applications, so it was not universal solution.
OLE:
In 1991 Microsoft created a more general solution to this problem called OLE . This technology allowed users to combine documents from multiple applications into a single compound document developers could build the best possible word processor without worrying about adding a limited function spread sheet. For example, we can embed excel worksheet into word document. The word document is acting as a container for excel worksheet. This is really the foundation of OLE. While working on OLE the Microsoft engineers recognized that the issue of creating compound documents was really a special case of determining how two or more system or application components communicate with each other. In the past a number of different techniques were employed. Some times simple subroutine calls were used. Other times more complex messaging systems was used. Programmers were often required to use several different techniques for communication among components. While implementing OLE Microsoft employed a number of new technologies; for most among them was COM.
COM:
COM creates a layer of abstraction between software components . Each COM object is designed to operate as a server to a client application or another software module. The COM object is an instance of a specific class that defines one or more interfaces to the functions it provides. Each interface contains one or more methods to perform specific functions. With COM, doesnt matter if the component is implemented as a simple set of subroutines as an independent process that communicates with the application using complex synchronization techniques.
Although COM determines how two components communicate with one another, OLE requires a number of other standard methods in addition to those required by COM. These includes the capability for the object to present its own user interface, send events to the controllers containers and lets a container sets the properties of the control.
OBJECT MANAGEMENT:
COM provides object management a service by using reference counting. With reference counting, COM enables developers to control when object references and their objects are released from memory.
OBJECT PERSISTANCE:
COM provides object persistence services that allow objects to be stored in a file. This is particularly important when you wish to extract an application specific object from a document file.
STRUCTURED STORAGE:
When objects are stored in files, they are stored using the structured storage services provided in COM. With structured storage we can store data in a hierarchical format within a file very much as files are stored in directories and sub directories. Structured storage allows applications to read and save items to files with out restricting the lay out of the file .
DATA TRANSFER:
COM provides DATA TRANSFER, a service that enable you to transfer and share data between applications.
interface card to create a value that is guaranteed to be unique on your system. If your computer does not have a network interface card, the GUID will be created from a value based on your hard disk space and the total time since the computer was booted.
INTERFACES
An interface is a contact between a COM server and a COM client. It specifies the methods, properties, and events that are used to communicate between the client and the server. This is perhaps the most important part of the COM object, because the interface isolates the internal working of the COM object from how it is used by the client. Every COM object presents at least two interfaces to the outside world. In most cases, more than two will be present because a number of interfaces are dedicated by the COM architecture.
BINDING TO AN INTERFACE:
In order to use a COM object, you must find and load the library containing the object. Then you must create a link between the object variable you plan to use and the desired interface. This process is known as binding. There are two basic types of binding: using. With early binding, you must declare your object variable with a specific object type with this information visual basic is able to bind your variable to the object at designed time. early and late. In late binding, visual basic is unable to determine the type of the object your are
Application program
COM Object
COM Proxy
COM Proxy