How to decide when to use object adapter and when to use class adapter?
Problem statement:
To create social networking web site and provide import functionality from facebook, google plus and orkut. I am unable to decide whether to use object adapter or class adapter.
I have had look at Adapter Pattern: Class Adapter vs Object Adapter, but could not understand the essence of the difference.
The main difference:
Class Adapter uses inheritance and can only wrap a class. It cannot wrap an interface since by definition it must derive from some base class.
Object Adapter uses composition and can wrap classes or interfaces, or both. It can do this since it contains, as a private, encapsulated member, the class or interface object instance it wraps.
The difference is subtle. Usually the later approach (favoring composition over inheritance) is the preferable as explained in the link which I’ll quote here: