Aggregation

You can think of aggregation as the COM version of inheritance. Quite often, you’ll have an existing COM object that you want to extend. Instead of changing the original component’s source code, you can extend its functions by creating a new “wrapper” COM type. Again, this is very object-oriented; you can expand on existing code simply by knowing the base component beneath its COM definition. The original component can be written in any language—Visual Basic, C++, or whatever—and the extended COM type can also be constructed in any language. It’s the ultimate in flexibility and code reuse!

Marshaling

When more than one process is active, a COM object can be in use in several execution threads at the same time. To avoid conflicts, COM implements marshaling, which is the packaging of parameters so that method calls can be invoked across thread boundaries with safety. This works in both standalone and distributed environments; in the latter case, the boundary is not between threads on the same machine, but between threads executing on separate but connected systems. COM also packages the return values for interthread components. Calls to COM will be like any other function calls.

For Java COM objects, marshaling is largely a hidden process managed by the operating system. Packaging goes on behind the scenes and ensures that communication across threads is reliable.

© 1997 by Scott Ladd. All rights reserved.