February 28, 2021
Hot Topics:

VB6 Programmer's Introduction to COM

  • By James Limm
  • Send Email »
  • More Articles »

Interfaces are really what COM is all about. I shall cover them in far greater detail in the next chapter (and indeed throughout the rest of the book). Basically, the interfaces of a component are the mechanism by which its functionality can be used by another component. The precise structure of an interface is defined by COM, but in essence it's just a list of functions implemented by the component that can be called by other pieces of code.

At this point, a brief discussion of clients and servers would probably be beneficial, as we'll be talking about them a lot throughout the book.

Clients and Servers

The term 'client/server' encapsulates two separate, discrete entities. These entities could simply be two components, two applications or even two computers. The client requires some service, and requests a server to perform this service on its behalf. The server performs the service and, if required, returns a result to the client.

For example, a client may need some data from a database. In this case, the server could simply be the database, or there could be some additional objects between client and database. In the latter case, these objects would be the 'server' from the client's point of view. From the database's angle, however, the objects form the client and the database is the server. In other words, the client/server distinction merely refers to a request for a service or services. The client does the requesting, and the server performs the request.

In terms of COM components, each component can act as both client and server. A server is a component that exposes interfaces and therefore a list of functions that a client can call. It follows that the client is a component that uses that interface.

COM enforces a strict separation of the client and server such that they only know of each other's presence by the existence of their interfaces. To a COM client, the server is really just a set of interfaces, and I'll have more to say on this subject in the next chapter.

Throughout the rest of the book, I'll be developing this definition of a component and its interfaces.

A Quick Aside

Again, don't worry about the definitions of components and interfaces; for now I just want to draw your attention to how they are drawn in these COM diagrams. The large box represents a component or an object, while the "blobs on sticks" represent the interfaces exposed by that object. For obvious reasons, COM diagrams like this one are sometimes called lollipop diagrams.

Page 3 of 12

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date