Jun 26, 2024
Right. A lot of people fall for this trap that "composition is better than inheritance" based on some deliberately crafted, over simplified examples. Once they see some significant codebases of software for modelling the real world (Physics engines, Biological Hierarchies, Electronic circuit simulators , GUI Windowing frameworks etc. ) and seeing the merits of inheritance in action, understanding the "is-a" vs "has-a" nuances , they would stray away from such juvenile thoughts. Honestly, almost all such comparison in the programming world that X is better than Y has weaknesses.