Adapter Pattern

  • Definition: Convert an interface to another interface that the client wants, so that those classes with incompatible interfaces can work together, and its alias is Wrapper;
  • Classification:
    • Object adapter: There is an association relationship between the adapter and the adapter;
    • Class adapter: There is an inheritance (or implementation) relationship between the adapter and the adapter;
  • default adapter
    • When you do not need to implement all the methods provided by an interface, you can design an abstract class to implement the interface and provide a
      default implementation (empty method) for each method in the interface, then subclasses of the abstract class can selectively Override certain methods of the parent class to implement the requirements; also known as the single-interface adapter pattern;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325124825&siteId=291194637