Value of Comments
16-May-90 00:46:03
Sb: #104853-Value of Comments
Fm: Don Curtis/SYSOP 76703,4321
To: Mike Spille/Manx 71545,1466
Mike,
You're right…IF the code you're looking at was written by a
semi-competent programmer. Unfortunately, much of the code I get to fix
was written by incompetent programmers. I've literaly cut the source code
just about in half just by re-writing the functions properly…let alone
debugging them.
For example:
a function that was called only ONE place in a program, was called
in the middle of a loop that was executed up to 60,000 times and the
function duplicated 1/2 the code in the calling routine AND duplicated it's
own code based on a range comparison (that could only have been 1 of 2
values).
I stripped the duplicate code, moved the function (what was left of
it) inside the loop, removed the range comparison (which was also done
60,000 times) and replaced it with a flag that was used as an index into an
array so the flag was set with a single range check.
This guy didn't know how to indent, used multiple forms of bracing
didn't use #define's for constants, and every other form of bad programming
you can think of…BUT, he was very liberal with comments. At least with
that…I had a clue as to what he was trying to do. Without the comments
it probably would have been better (and maybe faster) for me to have just
scrapped the whole thing and started from scratch.
With the comments…his code was salvageable. Without them it
would have taken me about 3 or 4 days just to figure out what he was trying
to do…and that's all it would have taken me to write it from scratch.
As it was…it was fixed in 2 days into a working, and efficient
program.
This wasn't an isolated example…it was unfortunately the norm for
quite a while.
Don