Decorator Pattern

A pattern that wraps an object to add behavior without changing its class.

What is Decorator Pattern?

The Decorator pattern wraps an object to add behavior without changing its class, like adding whipped cream to a coffee order. Wrappers can be stacked.

ICoffee order = new WhippedCream(new ExtraShot(new BasicCoffee()));
Console.WriteLine(order.Cost());

Level: Freelancer · More OOP terms at this level

Updated