Tuesday 3 April 2007

Adapter Pattern (blog 7)

We had an interesting class regarding Adapter pattern. I found this pattern very interesting because it allows us to make classes work together with the help of their interfaces, the interface of the classes will make classes work together which are incompatible to interact with each other. Adapter patterns are also known as Wrapper.
This pattern should be used in solving issues such as when you want to replace a class but the interface doesn’t match OR without knowing the interfaces of the classes when we want to create a class that could be used with some other classes.


Adapter Pattern has two types.

1.Object Adapter Pattern
This type of pattern has a technique in order to adapt an interface to another which I think I have never seen in any other pattern. According to the client requirement the adapter inherits the interface. Object adapters authorize the client and the adaptee to be completely decoupled from each other. Just the adapter knows concerning both of them.
2.Class Adapters
Multiple inheritance is used by class adapter to accomplish their goals. Class adapters are useful in situations like where there are some existing class provides services and doesn’t require to use the interface.