You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I have also found the following design pattern a useful one for this sort of tool: https://refactoring.guru/design-patterns/strategy. In this pattern, you have only one type of inheritance: implementations of abstract base classes. Again, this may be too extreme if some uses of inheritance are justified. But note that common code can also be wrapped in functions and used by different classes that way, rather than being inherited as a method.
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.
The text was updated successfully, but these errors were encountered: