官术网_书友最值得收藏!

  • Spring 5 Design Patterns
  • Dinesh Rajput
  • 150字
  • 2021-07-08 09:59:35

The adapter design pattern

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
-GoF Design Patterns: Elements of Reusable Object-Oriented Software

Adapter design patterns come under the structural design pattern, according to this design pattern two incompatible classes work together that couldn't otherwise because of incompatible interfaces. This pattern works as a bridge between two incompatible interfaces. This pattern is used when two inferences of the application are incompatible in their functionalities, but these functionalities need to be integrated as a business requirement.

There are many real-life examples where we can use the adapter pattern. Suppose you have different types of electric plugs such as cylindrical and rectangular plugs, as shown in the following figure. You can use an adapter in between to fit a rectangular plug in a cylindrical socket assuming voltage requirements are met:

主站蜘蛛池模板: 蕲春县| 响水县| 罗平县| 棋牌| 漠河县| 肇东市| 铁岭县| 新河县| 乐都县| 瑞安市| 阿鲁科尔沁旗| 遵义县| 开化县| 海淀区| 张家界市| 孝义市| 遂溪县| 山阴县| 广东省| 宁明县| 西安市| 嫩江县| 乐平市| 金沙县| 常德市| 淳化县| 弥勒县| 车险| 江源县| 遂川县| 林州市| 临沭县| 桃源县| 连州市| 新田县| 铁岭市| 台南市| 卢龙县| 乐东| 克什克腾旗| 博客|