Chapter 11: Design

CRAP score

Also called Change Risk Analysis and Predictions

One number combining how complicated a function is with how little of it the tests run. Complicated and untested scores terribly. Simple or well tested scores low. The formula is complexity squared, times untested fraction cubed, plus complexity.

It is a gate an agent can run and act on, because the score offers two ways out: simplify or test. And an agent will reach any number you set by the cheapest route, which may not be the route you meant.

Say it to your agent

“Run ./crapper --changed --threshold 10. For anything over 10, tell me whether it is one question (a single switch can stay) or mixed duties (split it). Don't add helpers that take booleans the caller already knew, and don't chase a lower score.”

The workshop

Name a word, or describe what you mean in everyday language.