User Tools

Site Tools


principles:add_more_classes

This is an old revision of the document!


Add More Classes

Variants and Alternative Names

Context

Principle Statement

“When things get too complex, add more classes.”1)

Description

Complexity can often be reduced by adding further classes that better separate concerns.

Rationale

Strategies

  • Divide larger classes into several smaller ones.
  • Use polymorphism, dynamic binding and abstract couplings.

Caveats

  • 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.

Origin

Grady Booch is sometimes cited like that. The precise origin is unknown. See AddMoreClasses.

Evidence

Relations to Other Principles

Generalizations

Specializations

Contrary Principles

  • 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.

Complementary Principles

  • 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.

Principle Collections

Example

Description Status

Further Reading

1)
Grady Booch as cited in AddMoreClasses
principles/add_more_classes.1362309948.txt.gz · Last modified: 2013-05-20 12:46 (external edit)