Wednesday, March 23, 2011

.NET and Java J2ee design pattern interview question :-What is the difference between Object and class adapters?


Answer:

Below are the main difference between these 2 patterns.
Object adapter
Can adapt classes as well as sub classes since uses composition

More flexible since dynamic polymorphism can be used with composition
Class adapter

Can adapt classes or sub classes not both. As a result no need to re implement the entire adaptee
More efficient since class adapter acts as adapter and adaptee

Please do visit my .NET Design patterns and Java J2EE design pattern interview questions

No comments: