Saturday, August 05, 2006

Adaptor pattern

Adapter pattern applies to the situation where you want to adapt a third-party class into your own domain. The third party component will has no knowledge of your design, so the only way you can use to create a an adapter class to use.

There are two ways to in this adaption approach. One is called "Class Adaptor". In this case, a multiple inheritance will be used. Normally, the class in your design will inherit from both the base class and the class you want to adapt. Another approach is called "Object Adaptor", in this approach, you will declare an object of the adaptee type in your adaptor class. (In some languages like c# which doesn't support the multiple inheritance, this may be the only choice available.)