22 Sep 2003 (updated 24 Sep 2003 at 11:55 UTC)
»
Gnome
The whole mahjongg business was getting me down, I had some working code and had removed a lot of the old "bad" code. So I left it for a few days. Got back to it last night and rewrote 80% of what I had previously written. The separate foregrounds and backgrounds are gone and the whole thing more-or-less works again. Well, the redrawing of individual tiles is broken, but thats because of a bug, not because of unwritten code. Some bits of code are inefficient place-holders, but all-in-all it looks a lot nicer and cleaner. It should be faster too (about five times faster redrawing the entire board, and it uses less memory). However it is still going to be some days before it is ready for CVS.
Bit-rot
gnome-games is a particulalry bad place for code. It gets left for a long time and slowly rots away. Looking at the mahjongg code you see functions that were obviously written one line at a time, each time by a different person fixing a different bug. Lines like:
#undef GNOME_DISABLE_DEPRECATED
do not inspire confidence either. The disturbing bit is that according to the ChangeLogs it was a good idea at the time. Of course mahjongg was at least initially written as a GNOME program. Gtali was originally a curses program that was ported to GNOME. The old code uses one CapitalisationConvention and the GNOME code uses another capitalisation_convention. There was also a very awkward separation of the code so that both curses and GNOME front-ends could be compiled from the same source. Fortunately the original source had been relatively clean when everything started.
The code really needs regular rewrites to clean up the mess that successive bug-fixes create. I try and be careful about the code I add: I try and fix the cause of a bug, not its symptom, but still everything decays. This is why I'm doing the big rewrite on mahjongg. I know that in six months time someone will look at my code and curse me, but it will be a lot better than if I hadn't touched it.
Life
Yes, I have one. It's kept in a locked box under my bed.