Design Patterns adapter mode

 

Adapter mode (Adapter Pattern) is used as a bridge between two of incompatible interfaces. This type of design pattern belongs structural model, which combines the functionality of two separate interfaces.

This model involves a single class that is responsible for adding separate or incompatible interface functions. For real-life examples, the reader is as an adapter between the memory card and laptop. Your memory card into the card reader, then the reader into the notebook, so you can read the memory card via a laptop.

 

Object Adapter Mode
  In this mode, the adapter, the adapter accommodating a wrapped it instance class.

Class Adapter mode
  In this mode adapter, the adapter to achieve their own inherited class.

 

Three parts:

  Target: target role, the definition of the other class into a role we expect

  Adaptee: initial role that our original class and interface objects, such as "A-> B", where A is the initial character, which is always present

  Adapter: Adapter role, which is our focus today, the adapter needs a new creation, through inheritance, etc. to the initial role reversal becomes the target role.

 

reference:

  Easy to understand series | Design mode (C): adapter mode

  Adapter pattern | newbie tutorial

 

Common learning and common progress, if any supplement, please point out, thank you!

Guess you like

Origin www.cnblogs.com/dengguangxue/p/11411136.html