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

Decorator design pattern

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub classing for extending functionality.
- GOF Design Pattern

In software engineering, the common intent of all GOF structural patterns is to simplify the complex relationship between objects and classes in a flexible enterprise application. The decorator pattern is a special type of design pattern among these that comes under the structural design pattern, which allows you to add and remove behaviors for an individual object at runtime dynamically or statically, without changing the existing behavior of other associated objects from the same class. This design pattern does this without violating the Single Responsibility Principle or the SOLID principle of object-oriented programming.

This design pattern uses the compositions over the inheritance for objects associations; it allows you to divide the functionality into different concrete classes with a unique area of concern.

Benefits of the Decorator design pattern

  • This pattern allows you to extend functionality dynamically and statically without altering the structure of existing objects
  • By using this pattern, you could add a new responsibility to an object dynamically
  • This pattern is also known as Wrapper
  • This pattern uses the compositions for object relationships to maintain SOLID principles
  • This pattern simplifies coding by writing new classes for every new specific functionality rather than changing the existing code of your application
主站蜘蛛池模板: 黎川县| 醴陵市| 岢岚县| 嵩明县| 苏尼特右旗| 大邑县| 旺苍县| 永仁县| 三亚市| 鹰潭市| 绥中县| 峨边| 内黄县| 枞阳县| 泰来县| 攀枝花市| 临湘市| 汉川市| 临漳县| 桓仁| 大渡口区| 宿松县| 资中县| 顺平县| 上思县| 湾仔区| 巴彦县| 株洲县| 香港| 方山县| 南岸区| 玉树县| 大城县| 西乌珠穆沁旗| 贵定县| 和林格尔县| 连州市| 定南县| 柳江县| 叙永县| 亳州市|