Jacobvu84 / design-pattern

0 stars 0 forks source link

Decorator #3

Open Jacobvu84 opened 3 months ago

Jacobvu84 commented 3 months ago

Mục đích chính của mẫu thiết kế này là cho phép mở rộng chức năng của các đối tượng tại run-time một cách linh hoạt mà không làm thay đổi cấu trúc của chúng.

Decorator pattern lets you dynamically change the behavior of an object at run time by wrapping them in an object of a decorator class.

In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern.

Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.

Jacobvu84 commented 3 months ago

Tham khảo