liveBook · Manning

Code design

As explained in Unit Testing Principles, Practices, and Patterns

A method for structuring software code to achieve desired qualities such as maintainability or testability.

Code design structures production code so valuable unit tests remain possible and software can grow sustainably. Testability is a useful warning signal, but not proof of quality. section 7.0 section 1.2

Judge design through two different signals:

  • Treat difficult unit testing as a negative indicator: it often reveals tight coupling and insufficient decoupling. section 1.2
  • Do not treat easy unit testing as a positive guarantee: highly decoupled code can still be poor quality. section 1.2
  • Prefer changes that protect against regressions, resist refactoring, provide fast feedback, and remain maintainable. section 7.0

Refactoring code design supports output-based testing and valuable tests across applications, including systems that cannot use a functional architecture. section 7.0

Figure 1.1. The difference in growth dynamics between projects with and without tests. A project without tests has a head start but quickly slows down to the point that it’s hard to make any progress.

Compare growth dynamics: projects without tests gain speed early but can slow into stagnation as software entropy increases. section 1.2

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Explains testability as a one-way quality signal and connects design work to testing, without detailing specific design techniques.
Examples
Uses an audit system refactoring and growth-dynamics figures contrasting projects with and without tests.
What it assumes
Assumes familiarity with unit testing and introduces the relationship between testability, design quality, and sustainable growth.
What you can do after
Evaluate code quality signals and refactor toward tests that protect behavior while minimizing maintenance cost.
How it connects
Connects code design with unit testing, tight coupling, functional architecture, output-based testing, and software entropy.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.