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

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
主站蜘蛛池模板: 丽水市| 加查县| 武山县| 洛浦县| 唐河县| 青河县| 娱乐| 汝阳县| 扎兰屯市| 巩义市| 衡山县| 华坪县| 红河县| 达州市| 平顺县| 辉南县| 灌南县| 上饶市| 衡阳市| 蓬安县| 商水县| 康定县| 遂川县| 长丰县| 昌都县| 诸暨市| 武山县| 阿尔山市| 页游| 上栗县| 苏州市| 乌拉特中旗| 惠安县| 灵石县| 新田县| 昌平区| 盐边县| 九江县| 鹤峰县| 蒲江县| 普洱|