Our brain work responding to the external input. That is the way we think. You tend to think more when more external input comes. Our thoughts slow down when we don’t have input. So we have to come up with a way to keep input flowing into us for efficient work.
I use a piece of memo, actually a page on Emacs, to direct myself.
For programming, I write what I have to do. I break down the list until they become concrete enough, usually the line is going to be translated into a few lines of program. Then I start writing the program whichever order I like. Because everything is listed, I would not drop anything. As programming makes progress I cross out the lines from the memo. I may add some lines when the new items come up. In the end, the memo becomes empty and the program is done.
For debugging, I write all the findings and possible experiments, so that I don’t drop any possibilities. Then I start looking at each of the possibilities in any order I would like. Not like for programming, I do not erase the lines as debug goes on. I only write more findings and possibilities. Obsolete lines goes to the bottom of the memo. At the end of the debugging, I get a messy
debug note, which I just keep for future reference.