posted 08-06-99 05:59 AM ET
Whatever JKM may have said, there is only one way that a bug enters software: it is designed in.There is only one way that a bug is perpetuated from one product to another: the design is copied.
As previously stated, it is apparent that BR has a copy of the source of Civ2, and that SMAC was built by modifying that source.
Hopefully there are no legal issues for Firaxis or BR in editing the source of what became another company's property.
Perhaps it was done with the full consent of Microprose/Spectrum Holobyte/Hasbro, who surely retain much respect for SM and BR, as their own efforts have not always improved the product.
My main concern is that the design of Civ2 and consequently SMAC, is evidently not amenable to significant correction of many pervasive errors and weaknesses.
One reason for this is already known: the source does not reuse its own code, it repeatedly reinvents the code, approximately - a very bad programming practice. This is why the internal calculations and the user-side estimates of various deterministic quantities are in disagreement. Obviously, if the same functions and formulae were used in both cases, the results would always agree.
Secondly, the code is not adequately modularised. If it were, BR could put his finger on exactly where the missile range bug came/comes originates.
How do we recognise a bug? Every inconsistency is a bug. For example, when documentation disagrees with code, then they are both to be examined for error.
Bug-free complex software, does it exist? That may be difficult to prove conclusively, but programmers can at least write sanity checks at each entry and exit point.
What do we check for? To answer that, go back to the intention of the code, and analyse it top-down (or outside-in, as I prefer to describe it). Does each code section correspond to a clear intention? Does it manifestly implement that intention?
If you can't provide valid tests, in the code, that the values of the variables entering and leaving each section of code satisfy the intention for that section, then your program is written to be faulty.
What do these tests cost? Very little in time, and very little in space.
Often similar tests are required in many locations in the source. A very simple example is a test in C that a pointer to supposedly allocated memory is not NULL.
Several of the standard library functions in C are not logically valid, and therefore not safe. Classic examples include gets(), which should never be used; instead, one should use fgets() or write one's own, valid, string reading function.
When is code logically valid? When it peforms a clear function, tests the validity of its input, only accepts valid input, and its output is always correct for that input.
Sounds simple. The wonder of it is that it _is_ simple. The shame of many programmers is that they don't practise it.
Clearly Civ2 was written at a time when Sid and Brian were not in the habit of sound programming practice, and SMAC has inherited the consequent flaws. So it is, not surprisingly, partly incorrigible and unmaintainable.
Given software of this nature to further develop, I seek to analyse the intentions of its authors, then write replacement code that not only does the job correctly, but also throws a mighty big flag if anything at all untoward occurs. "Hey! You who are running me! This data is bad, and it went bad here!"
And when I say data, I do not mean "Register XYZZY contains $01c3fda5". The code is designed to reflect its author's intent, so it knows the same concepts that the author had in mind, so it says:
"Missile has gone out of range, because in the missile_movement() function you forgot to put in a check to stop it! If you imagine I'm going to let you spoil some poor gamer's day, forget it! The buck stops with you! Now!"
There's nothing fanciful about that degree of "intelligence", by the way, no matter what some programmers may say. Basic sanity checking of high-level objects and functions will achieve it with less effort than it takes to write (let alone "debug") the more bug-ridden, bug-hidden version.
Unfortunately, bad habits are a form of hard-to-eradicate bug in poorly self-constructed mental software.