Professional Documents
Culture Documents
1
1
Programmers are rarely totally satisfied with their code. After I wrote the
program for my article on polymorphisma simple parser-calculatorI
immediately noticed that I could have done it better. I felt that the top-level
view of the program was not very clear. The nodes of the parsing tree needed
access to components such as the Store (the calculator's "memory"), the
symbol table (to print meaningful error messages), and maybe even to the
function table (to evaluate built-in functions). I could have made all these
objects global and thus known to everybody, or passed references to them to
all the nodes of the tree.
The order of construction of these objects was important, so I felt that maybe
they should be combined into one high-level object, the Calculator. The
temptation to redesign and rewrite the whole program was strong. Maybe
after the nth iteration I could come up with something close to the ideal?