Ramifications

[Previous] [Next]

COM supports the concept of local/remote transparency. This means that when a client obtains a reference to a COM object that supports the interface the client expects, the client will receive a direct reference to the object in memory, providing the object resides in the client process's address space. If the COM object does not reside in the client process's address space, COM will interpose and create a proxy object in the client process's address space that supports the same interface as the real object residing out-of-process. The proxy object maintains an internal reference to the real object. All submissions to the proxy are packaged for out-of-process travel and forwarded to the real object. This marshaling feature of COM is transparent because it requires no programmer intervention. ActiveX component projects are deeply rooted in COM; hence this feature also applies to Visual Basic.

A proxy provided by COM is considered dumb because it does not intelligently decide how to handle each unique request to the real object—all requests are simply forwarded to the real object. This can have a severe impact on performance depending on the volume of submissions.

The use of a smart proxy is a solution that will alleviate the impact on performance without compromising the principles of object orientation. Keep in mind that a smart proxy might prove useful in other scenarios (as briefly stated in the "Utilization" section). The implementation of a smart proxy requires programmer intervention, however. The programmer must define a class that implements the same interface as the real object. Within the class implementation, the programmer must decide when to delegate requests to the real object. Furthermore, the programmer must ensure that the smart proxy object is loaded in the client process's address space.

Using the Smart Proxy design pattern can be advantageous, but don't ignore the price of maintenance.



Microsoft Visual Basic Design Patterns
Microsoft Visual Basic Design Patterns (Microsoft Professional Series)
ISBN: B00006L567
EAN: N/A
Year: 2000
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net