I googled and investigated, but I still need some clarification: Are an adapter class and a controller class similar? If not, in what way they do differ?
Kindly explain.
Adapter in C++ An "adapter" class is defined that publicly inherits the interface of the abstract class, and privately inherits the implementation of the legacy component. This adapter class "maps" or "impedance matches" the new interface to the old implementation.
Adapter is a structural design pattern, which allows incompatible objects to collaborate. The Adapter acts as a wrapper between two objects. It catches calls for one object and transforms them to format and interface recognizable by the second object.
The adapter class implements the expected interface and keeps a reference to an object of the class you want to reuse. The methods defined by the interface call one or more methods on the referenced object and return a value of the expected type.
Adapter is a pattern that provides default (often empty) implementation of interface or abstract class. For example MouseAdapter
provides empty implementation of MouseListener
interface. It is useful because very often you do not really use all methods declared by interface, so implementing the interface directly is very verbose.
Controller is a part of MVC - Model-View-Controller pattern. No direct relation with Adapter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With