+1 vote
in Design Patterns by
Give an example of decorator design pattern?

1 Answer

0 votes
by

The decorator pattern, also known as a structural pattern is used to add additional functionality to a particular object at runtime. It wraps the original object through decorator object. For example, when you are buying a burger, you can customize it by adding extra filling and sauces, now the cost of these items have to be added to the final price. The customization will differ from customer to customer and offer from a shop. Creating different classes of burger with different fillings will end up creating a lot of classes. Decorator solves this problem by extending the functionality of single Burger class at runtime based on customer request.

Related questions

0 votes
asked Jul 24, 2023 in Design Patterns by SakshiSharma
0 votes
asked Jan 2, 2021 in Python by SakshiSharma
...