Posts

Showing posts with the label composition

The Split in OOP: Compositional vs. Genealogical Design

The Two Faces of Object-Oriented Programming: Inheritance vs. Composition Object-oriented programming (OOP) has evolved over the decades, branching into two distinct paradigms that shape how developers model and structure their systems: genealogical (inheritance-based) OOP and compositional (composition-over-inheritance) OOP. While both approaches fall under the OOP umbrella, they reflect fundamentally different philosophies on how to build and organize behavior. 🔹 Genealogical OOP (Classical Inheritance) This is the traditional, textbook model of OOP. In this approach, classes form hierarchies where child classes inherit behavior and structure from parent classes, a lineage that resembles a family tree. This is the familiar “is-a” relationship. Common Languages : Java, C++, classic Python, Ruby Key Characteristics : Emphasis on class hierarchies Behavior is reused via subclassing Polymorphism is achieved through inheritance Often leads to deep class trees that can beco...