Categories

Oct 17, 2019 in Design Patterns

Q: Give an example of decorator design pattern?

1 Answer

Oct 18, 2019

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.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Oct 17, 2019 in Design Patterns
Oct 16, 2019 in Design Patterns
Oct 17, 2019 in Design Patterns
...