Skip to main content

One doc tagged with "design-patterns"

View all tags

Composition vs. Inheritance

In Object-Oriented Programming, there are two primary ways to build relationships between classes and reuse code: Inheritance and Composition. While we have already covered inheritance, it's crucial to understand its alternative, composition, and to know when to choose one over the other. This choice is one of the most fundamental design decisions you will make when structuring your programs.