next up previous
Next: References Up: External Polymorphism An Object Previous: Known Uses

Related Patterns

This pattern is similar to the Decorator and Adapter patterns from the Gang of Four (GoF) design patterns catalog [1]. The Decorator pattern dynamically extends an object transparently without using subclassing. When a client uses a Decorated object it thinks it's operating on the actual object, when in fact it operates on the Decorator. The Adapter pattern converts the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

There are several differences between these two GoF patterns and the External Polymorphism pattern. The Decorator pattern assumes that the classes it adorns are already abstract (i.e., they have virtual methods, which are overridden by the Decorator). In contrast, External Polymorphism adds polymorphism to concrete classes ( i.e., classes without virtual methods). In addition, since the Decorator is derived from the class it adorns, it must define all the methods it inherits. In contrast, the ConcreteCommon class in the External Polymorphism pattern need only define the methods in the Concrete class it wants to treat polymorphically.

The External Polymorphism pattern is similar to the GoF Adapter pattern. However, there are subtle but important differences:

  1. Intents differ: An Adapter converts an interface to something directly usable by a client. External Polymorphism has no intrinsic motivation to convert an interface, but rather to provide a new substrate for accessing similar functionality.
  2. Layer vs. Peer: The External Polymorphism pattern creates an entire class hierarchy outside the scope of the concrete classes. Adapter creates new layers within the existing hierarchy.
  3. Extension vs. Conversion: The External Polymorphism pattern extends existing interfaces so that similar functionality may be accessed polymorphically. Adapter creates a new interface.
  4. Behavior vs. Interface: The External Polymorphism pattern concerns itself mainly with behavior rather than the names associated with certain behaviors.

The External Polymorphism pattern is similar to the Polymorphic Actuator pattern documented and used internally at AG Communication Systems.

0=6 =0.90 .55 -0 =.9

0


next up previous
Next: References Up: External Polymorphism An Object Previous: Known Uses

Chris Cleeland
Tue Oct 22 01:20:58 CDT 1996