Table of Contents
Add More Classes
Variants and Alternative Names
“When things get too complex, add more classes.”1)
Complexity can often be reduced by adding further classes that better separate concerns.
- Divide larger classes into several smaller ones.
- Use polymorphism, dynamic binding and abstract couplings.
- Adding too many classes leads to ravioli code. Which may be hard to grasp and debug.
- Classes need to be separately understandable (see PSU).
See section contrary principles.
Grady Booch is sometimes cited like that. The precise origin is unknown. See AddMoreClasses.
Relations to Other Principles
- High Cohesion (HC): Add more classes is a direct result of HC.
- More Is More Complex (MIMC): Add More Classes decreases complexity with respect to the size of the classes on expense of increased complexity due to the number of classes. There is always a tradeoff to be made. Add More Classes tells that an increased number of classes often is the lesser evil while MIMC explains the tradeoff to be made.
- Encapsulate the Concept that Varies (ECV): ECV tells how to separate concerns when add more classes shall be used to lower complexity.
- Model Principle (MP): While adding classes MP should be considered in order to find appropriate concepts for encapsulation into a class.
Discuss this wiki article and the principle on the corresponding talk page.
Grady Booch as cited in AddMoreClasses
principles/add_more_classes.txt · Last modified: 2021-10-18 21:20 by christian