Compiler

Monday, 23 July 2001
Compilers sometimes are a blessing, sometimes a curse.
  • A blessing some developers say. A compiler eases the path to quality software, as the compiler spots bugs in the code before the program runs. Yes, true. Compilers are a blessing for syntax and spelling errors.
  • A compiler forces you to think properly about everything, before the first statement executes. Hmm. Is that really such an advantage?

    A long march starts with a first step. And I'd like to test this first step before I make the second one. Two halves are easier than the whole.

  • A drawback is that the compiler is limited to syntax and logical errors, as it does not know runtime values. Java-objects in a Vector are notorious for their ClassCastExceptions (java.sun.com/.../ClassCastException...).
I prefer to work top down especially when I am developing complex software.
  1. Top Down Depth First Write the high level methods first. These call lower level methods, which do not exist yet.
  2. The software runs into an error, of course. And that is exactly what should happen. I use the debugger to see if everything so far has gone according to plan. Only then do I write a lower level method, which will call even lower level methods.

    An interpreter allows me to focus my mind on one branch, the green part of the tree. I can test this branch separately, before I need to think about all other branches.

  3. Finally I reach the bottom, such as getters & setters. And everything works, top to bottom.
So, start small, solve small bugs and work towards a big success, not vice versa.
  • This top-down-depth-first method works very efficient. Only the required methods, which do not exist yet, require development effort.
  • In addition the top-down-depth-first method increases software quality. As a result of the intermediate debug inspections I am sure that the program is rock solid at a high level, before I would waste any time on lower methods. Some methods are reusable in other branches, and well tested too.
Thesis: It's not a compiler, but an interpreter that eases the path towards quality software.

Till next week,
Nut