Design Patterns Series 3 - Decorator Pattern
In previous post we explored Strategy Pattern, today we will explore another design pattern, that take care of flows in standard OOP especially when it comes to inheritance. Decorator pattern : The decorator pattern is perfect for the opening scenario, it's all about extending the functionality of given class. After you have written a class you can add decorators(additional classes) to extend that class, that mean you will not have to keep modifying the original class's code over and over again. It allows you to write your code and avoid modification, while still extending that code if needed. So as much as possible design your core code so that it doesn't have to be modified a lot, but may extended as needed. If you want to write a code to produce a car with description as " this is a new car ", so the class car will be like the following public class Car { public Car() { } public String Description() { return "that is a new...