The object adapter and class adapter pattern are two paterns to allows you to provide an object instance to a client that has a dependency on an interface that your instance does not implement.
The unique different is that lass adapter uses the inheritance for the adapter and object adapter uses the composition, these patterns are the same behavior.
Which is the better?The most of developers are told to favor composition over inheritance because that inheritance is whitebox reuse that means that you know how is implemented and this increase the complexity of the code and prevents the adaptability to other situations.
The composition makes the subclass dependent merely ons ist interface, which is blackbox reuse so that the implementation can vary without adversey affecting clients.
Main photo by Liam Briese at Unsplash.
Thank you for reading and if you have a question use the comments!