Optimize for Reducing State, Coupling, Complexity, and Code

To optimize code, reduce state, coupling, complexity, and code, in that order. Reducing state makes the program easier to reason about (e.g. pure functions are easy to test). Be willing to add more coupling if that means less state, more complex if it decreases coupling, and duplication if it makes code less complex.

Read the HN thread.

See also: