Adapter Pattern Object In Java
While implementing adapter pattern there are two approaches class adapter and object adapter however both these approaches produce same result.
Adapter pattern object in java. An adapter wraps an existing class with a new interface so that it becomes compatible with the client s interface. Two way adapter pattern while implementing adapter pattern there are two approaches class adapter and object adapter however both these approaches produce same result. It catches calls for one object and transforms them to format and interface recognizable by the second object. There is also another type called class adapter pattern which use inheritance instead of composition but you require multiple inheritance to implement it.
Class adapter this form uses java inheritance and extends the source interface in our case socket class. Object adapter vs class adapter the adapter pattern we have implemented above is called object adapter pattern because the adapter holds an instance of adaptee. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. The adapter acts as a wrapper between two objects.
Class adapter this form uses java inheritance and extends the source interface in our case socket class. This tutorial demonstrates how to use the adapter pattern in java focusing on use cases and types of adapters class object and two ways adapter patterns. Adapter is a structural design pattern which allows incompatible objects to collaborate.