personal-page/_master_wiki/void/Readwise/Understanding Composition in Software Development.md

2.1 KiB
Raw Permalink Blame History

Understanding Composition in Software Development

rw-book-cover

Metadata

[!tldr] Composition is a software development principle that emphasizes building complex systems by combining smaller, independent components rather than using inheritance. This approach offers flexibility, reusability, and easier maintenance, making it a popular choice among developers. By favoring composition, developers can create more adaptable and manageable systems.

Highlights

At its core, composition is about constructing complex systems by piecing together smaller, distinct objects. In object-oriented programming lingo, we often describe it as a “has-a” relationship rather than the “is-a” relationship that comes with inheritance. View Highlight)

Flexibility : As requirements change, its easier to swap or upgrade individual components without disrupting the entire system. Reusability : Crafted correctly, components can be used across various parts of a project or even in entirely different projects. Maintainability : Focused and modular components are easier to understand, test, debug, and enhance. Reduced Side Effect : Unlike inheritance, where modifying the base can have widespread consequences, composition limits the ripple effect of changes. View Highlight)

When facing a complex problem, ask:

  • Which components make up this system?
  • How can I break this down into smaller, more manageable pieces?
  • Can I reuse existing components? View Highlight)