8: Explaining Variables
Some expressions grow. Even if they start small, they grow, and grow.
Later on, we return and try to understand what is happening.
When you understand part of a big, hairy expression, extract the subexpression into a variable name that captures the intention.
This is often seen in graphics code:
Before changing the expression, tidy it first:
In this tidying we're taking the hard-won understanding and putting it back into the code. Changing the expressions is now easier. Next time, they'll be easier to read.
As always, separate the tidying commit from the behavior change commit
Last updated