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

  • 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:

主站蜘蛛池模板: 贵南县| 泰宁县| 海丰县| 南部县| 黄大仙区| 绥滨县| 苏尼特左旗| 新平| 亚东县| 许昌县| 凤山市| 荆门市| 平遥县| 德阳市| 闸北区| 贵港市| 富蕴县| 武威市| 天祝| 大邑县| 宁德市| 宜阳县| 青州市| 荔浦县| 屯留县| 和平区| 祁门县| 繁昌县| 渭源县| 松原市| 凤凰县| 巩义市| 永川市| 乡城县| 资源县| 临武县| 洛扎县| 贵州省| 湖南省| 武胜县| 青海省|