Composition for better testability?

Thu Apr 1 2021

How many times did you want to test a class which inherits another class? Probably quite often. And how often did some property or method from the base class your life pretty difficult because you couldn’t test the actual system under test? I guess quite often as well.

Inheritance is not bad in general but sometimes in the object-oriented paradigm, you’ll find big hierarchy structures which make testing almost impossible.

Of course, good software architecture and design avoid those scenarios. Today I want to look at one best practice, called “favor composition over inheritance” which untangles those hierarchy structures in your application. For that I want to discuss the following points:

Read the full post at!