Wednesday, August 16, 2006

They told me so, but it didn't help

While implementing the last feature I discovered a bug in the cmdwin code that's exposed with the reduced screen-size version of the UI. The cmdwin strings are overrunning their little box on the display and trampling right over the frame border. After messing with it a bit I realized that I had implemented the wrong API for the cmdwin. During command prompts the code is always printing, and backspacing, and doing little tricks to keep track of how much to backspace. It became suddenly clear to me that the API should be a stack. You push a fragment of a prompt, then pop it, push the reply, and go on with the next fragment until the command is complete, then you wipe it clean and start over on the next command.

The new API is implemented and now I'm waist-deep in the muck of wading through all the commands and fixing them to use it. Programmers naturally hate this kind of drudge work, which is why it's a 100 billion-dollar industry or something to publish books about how to use some new approach to write your code so that this isn't necessary. I used to read those books until I realized that they all depended on one critical faculty which I do not possess: the ability to predict the future.

Now I just hold my nose and wade through the muck. It's faster than reading those books and less stressful than worrying if I've predicted the right future when I wrote my code. And it gets me re-acquainted with code I haven't visited in years, which is always good for a laugh or two at my younger self's expense.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home