D2X-XL Worklog
Notes on features and problems from the development of D2X-XL, newest first.
Major Code Revision |
|
The last weeks have seen me refactoring considerable parts of D2X-XL to C++ class based code. One benefit of this code overhaul is
the significantly improved structure and readability of the affected code. The major advantage however was the ability to overload
operators and do extensive checking of the involved operations. This particulary concerns array accesses, which until now I just trusted
to work, with program crashes being the only hint that something was fishy here. With C++, I can create array classes that overload the
index operator "[]" and put a function behind it that checks whether the index is within the bounds of the array. I can also
check whether a pointer to an array element actually points into the array, and properly points at the start address of an array element.
These enhancement revealed quite a few long standing bugs in D2X-XL that may well have caused the problems some D2X-XL users were constantly facing.
Actually, when seeing some of these bugs I wondered how D2X-XL had ever been working at all. Another big advantage of C++ I have been employing are template classes. I will spare you any explanations: If you are a programmer, you will
either know about this or be able to find some good information about this with Google, and if you are not a programmer, you wouldn't understand
a single word of what I'd be writing here. The price of using these C++ features was that I had to recode a lot of stuff into properly working objects using constructors and destructors, and couldn't just wipe all D2X-XL data clean with one big "memset(&data, 0, sizeof (data))". Actually this is more of an advantage than a disadvantage, as you can now rely on each object to properly release all system resources it has claimed at the end of its lifetime - provided you have set the destructor properly up. I could have used STL or LOKI with their mighty features, but my approach to restructuring the code was to create just what I needed; so I built my own "lightweight" classes and templates that fit exactly to my program. This had the advantage for me that I always knew perfectly what my code was doing, and that it wasn't capable of doing anything I didn't need or didn't want it to be able to (with the effect of hiding flaws in my code because it could somehow handle them, or (mal-) function despite of them without me noticing it). Such massive change in D2X-XL's code base can of course introduce new sources of errors, and I will not promise that everything will work perfectly right off the bat. The foundation for a better code quality has however been laid now, and the long beta test phase of the upcoming D2X-XL release has helped to find and eliminate a lot of bugs. The Mac OS X port also seems to be coming along nicely, so I am confident that v1.14 will work reliably and hassle free right when it is released.
|




Template classes helped me to very easily generalize a lot of basic
code and have the testing functionality described above quickly available in all parts of the program.