Java Child / The Four Moves Everything Is Built From

Doing Things In Order, And Only Then

Sequence and condition are the first two moves, and almost every early mistake involves confusing one for the other.

Sequence sounds too obvious to discuss. Do this, then that. Yet order carries enormous meaning, because each step arrives in a world that the previous steps have already changed. Swap two steps that look independent and the result can change completely, because one of them was quietly relying on something the other had prepared. Beginners often think of a set of instructions as a list of intentions gathered together. It is better to think of it as a chain, where each link is only sound because of what came before it.

The second move is choosing. Something happens only when a condition holds. This introduces branching, and with branching comes the first real cognitive load, because now the instructions describe several possible histories rather than one. The discipline here is to name every branch, including the one you did not write. If you have described what happens when a thing is true, you have implicitly described what happens when it is false, and leaving that implicit is how programs end up doing nothing at all in situations you never considered.

Conditions also invite a subtle error of thought: assuming that because two situations feel similar they can share a branch. Similar is not the same. When you find yourself hesitating over whether a case belongs on one side or the other, that hesitation is information. It usually means the condition you have written is not the condition you actually care about, and that the real question is one layer beneath the one you asked.