Composite over inheritance is an OOP design principle we’ve followed for several years. Like me, you might have seen it in the Effective Java book, and we have wanted to pursue it since then. 

The inheritance brings several pitfalls, such as maintainability and a clear code. Beyond the semantics, the sample that I love to use is the cake that needs Salt. It does not make sense for a Cake to extend a Sea only because it needs Salt. In this case, it is a much better composition as well. 

Generated by Feedzy