Tuesday, January 29, 2008

Switch Between Analytical and Empirical Hat in Coding to Avoid Blocking

Programmers has two hat that he can switch around to avoid blocking when coding. Those two are the Analytical (thinking, elaborating and tracing logic) and Empirical hat (Debug, print and compare values). Without being aware of this, I find that I sometime spend too much time in one mode that if I just switch to another mode when things seems getting hopeless in the current mode it could be a lot faster. Being flexible in switching mode could speed up and ease up the problem solving process. It'll make things more fun too, almost like playing a game.

Being Analytical is when you review the structure and logic of program, class design, association, hierarchies, call sequence and finally find out what to do. Being Empirical is just give the program the input, trace, see the real numbers and values, and review the output.

Blocking in analytical mode is when you find reviewing the structure and logic seems to get you nowhere, the class seems ok, the function and logic looks alright but the output is wrong. Blocking in empirical is when the input and output does not reveal to you any pattern on insights on what's going on.

Our brain seems to need both concrete/empirical and conceptual input in problem solving. The empirical test could help us understand part of the logic that might not get into our attention when relying only on static analyzing. The analytical view could shed us some lights on the problems in it's substantial level that the output fail to give us any concrete things to work on.

In coding, when reviewing why something does not work, I usually start with analytical review and if it's not solving anything, I just start tracing, dumping values, debugging. Sometime in the middle of tracing and debugging I got another idea to review certain part analytically. I just need to remember not to push to solve the problem in one mode if it does not seen to bear fruit and start to see it with another perspective.

Of course, when both are fail, taking a break would probably the best thing to do. But that's another issue and would require another discussion. The point is to avoid being sucked by the problem and utilize different perspective to keep things in control and most importantly, to keep it fun.

No comments: