Skip to content

Prefer composition to inheritance #71

Description

@lukethehuman

The current version of blobmaker relies heavily on inheritance. In general, it is preferable to use composition instead of inheritance.

The following video does a good job of demonstrating why and how to do so: https://www.youtube.com/watch?v=hxGOiiR9ZKg. In a nutshell, it can lead to expensive and messy refactoring when the inheritance tree gets sufficiently complex.

It might be that many instances of inheritance are justified, but it could be worth identifying where composition could be used instead to improve the code. The cases where inheritance is justified will be the cases where a composition pattern would lead to too many lines of copy and pasted code for the common functionality. Essentially, we have to trade-off between the rigidity of inheritance and the repetitiveness of composition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions