The main motivation before the decorator pattern is to be able to add data and behavior to objects dynamically without relying on inheritance. A decorator usually conforms to the interface of the component its decorating. Lets see this with an example. Am building a system that calculates the price of a pizza. I can have many toppings and the total price of the pizza is calculated based on what toppings I pick. One way to do this would be to use inheritance and class hierarchies like Pizza, CheesePizza, ......