A while ago, I started applying the Pomodoro technique in my work days, which essentially says that you must pick some tasks to do, and start doing them one by one. It talks about time-boxing, giving yourself breaks in between, handling interrupts, etc. But the main point is: do only one thing at a time, and handle all distraction in a way that they don't disrupt your focus.
It was a pretty successful experience. It increased my focus. It also helped me become more proactive, that is, doing what I think is effective to do, in the midst of all the things that world throws at me.
Now, on an entirely different planet, I was reading Michael Feathers’ book, Working Effectively with Legacy Code. In chapter 23, he says:
“I have this little mantra that I repeat to myself when I'm working: "Programming is the art of doing one thing at a time."”
This quote is from a chapter named “How do I know that I’m not breaking anything?”. So, doing this will increase the quality of the code you’re writing and decrease the possibility breaking something.
And it perfectly resonates with me. Every time I try to make many simultaneous changes to the code, it makes me more nervous, and I fall into the “code-and-pray” mode.
Even when I’m just trying to accomplish one single goal, I break it into smaller steps like "introduce a new constructor argument of type IFoo", "Write a new implementer of IFoo that does this and that", "Pass that new implementer as the constructor argument to the first class and make sure they work fine together" (ok, you get the idea), do them separately, and make sure that the tests pass after each one of them.
From now on, I will repeat this mantra to myself and advertise it to others too: “Programming is the art of doing one thing at a time.” When you stumble upon some ugliness or some unrelated thing that you want to change in code, just note it down to do later, and continue with the task in hand. It also helps you to check-in your code more frequently, which is always a good thing.
