Tuesday, May 08, 2007

WEEK FOUR - Adapter Pattern

Adapters come in two, object adapters and class adapters. These two methods to express the difference between the use of inheritance and composition to solve problems.

Class adapters have a problem with name conflicts if methods of the same signature exist on both the target and the adaptee. Just because two objects have methods that have the same signature, it does not guarantee that the two methods have the same meaning or behavior. That is, the two methods do not necessarily map directly to each other. Object adapters do not have this problem.

Class adapters are simpler than object adapters in that they involve fewer classes and are useful if total decoupling of the client and adaptee is not needed.

No comments: