Trivial code has low complexity, little domain significance, and few or no collaborators. Parameter-less constructors and one-line properties are typical examples. section 7.1
Classify code by complexity or domain significance and collaborator count:
- Treat domain models and algorithms as the strongest candidates for unit tests because they combine high value with low maintenance cost. section 7.1
- Skip tests for trivial code because their value is close to zero. section 7.1 section 7.6
- Test controllers briefly through integration tests, and split overcomplicated code into controllers and complex logic. section 7.6
Typical trivial code
A C# parameter-less constructor or one-line property usually belongs in the trivial-code category when it has few or no collaborators and little domain significance. section 7.1
Figure 7.1. The four types of code, categorized by code complexity and domain significance (the vertical axis) and the number of collaborators (the horizontal axis).
Use the four-quadrant classification to compare complexity or domain significance against collaborator count. section 7.1
