One of popular interview questions is: “please describe the four characteristics of object-oriented programming”. In my observation, not many candidates — even the senior ones — can explain well Abstraction, Encapsulation, Polymorphism, and Inheritance. Worse, little did they know the drawback of Inheritance.
Continue reading “The three characteristics of OOP”
An inherent concern of OO design: how can we extent a class without modifying its content? If we can do that, we satisfy the Open/Closed Principle (the O in SOLID).
Let’s take an example, a class
Rectangle with a method
Continue reading “Decorator pattern: decorators still need to be reused”