97 Things Every Programmer Should Know

(Chris Devlin) #1

Collective Wisdom from the Experts 95

What would the first two programmers do if their tasks took more than two
hours? After realizing they had taken on too much, they would most likely
throw away their changes, define smaller tasks, and start over. To keep work-
ing would have lacked focus and led to speculative code entering the reposi-
tory. Instead, changes would be thrown away, but the insights kept.

The third programmer might keep on guessing and desperately try to patch
together his changes into something that could be committed. After all, you
cannot throw away code changes you have done—that would be wasted work,
wouldn’t it? Unfortunately, not throwing the code away leads to slightly odd
code that lacks a clear purpose entering the repository.

At some point, even the commit-focused programmers might fail to find
something useful they thought could be finished in two hours. Then, they
would go directly into speculative mode, playing around with the code and, of
course, throwing away the changes whenever some insight led them back on
track. Even these seemingly unstructured hacking sessions have purpose: to
learn about the code to be able to define a task that would constitute a produc-
tive step.

Know your next commit. If you cannot finish, throw away your changes, then
define a new task you believe in with the insights you have gained. Do specula-
tive experimentation whenever needed, but do not let yourself slip into specu-
lative mode without noticing. Do not commit guesswork into your repository.

Free download pdf