[MUD-Dev] Clean Code (was:TECH: reliablity)

Dave Rickey daver at mythicentertainment.com
Tue May 1 15:55:04 CEST 2001


-----Original Message-----
From: Alex <fletchra at qsilver.queensu.ca>

> On Mon, 30 Apr 2001, Derek Snider wrote:
>> I know how to write clean bug-free code.

> There was an interesting debate about this on comp.security.unix last
> week.  I won't rehash it here, but suffice to say, the general feel
> was that one or two people claimed that they could write bug-free code
> and had scripts/programs/etc that would find any bugs that they
> happened to write when sleepy.  The rest questioned this and asked for
> the programs so that they could help everyone.  The 'bug-free' people
> seem to have since vanished.

Once upon a time I was a programmer (all of 2 years ago).  I was very
much of the school "90% of efficiency is design, the rest is what they
invented profilers for."  Clean, readable, straightforward code was
what I did, I tended to use the simple "brute force" techniques by
preference and get fancy later if I needed to.  The extended Pareto
Principle: 20% of your code is doing 80% of the work, 4% is doing
nearly two thirds, almost 2/3 of your code has no meaningful effect on
performance.  Design at length, burn the prototypes, get it *working*,
then find that 4% and optimize the hell out of it.  Sometimes the
straightforward approach is more efficient: Hand a list to a bubble
sort with only one element out of place and it will be done in one
pass, do the same with a quick sort and it will take as long as if you
handed it random numbers.

More to the point, I rarely handed off a project and had anyone come
back to me going "What did you do *here*?"  It was easy to figure out
where to optimize, frequently even without running a profiler, and
even easier to find bugs.  Also, there were a lot *less* bugs in the
first place, in my experience hard to duplicate bugs were usually the
result of code that got too clever.

Well, what I've seen in the games business is the cowboy hacker myth
run rampant.  Obscure code, neat hacks, inline ASM just because they
can.  It seems to be most game programmers feel "If you can read my
code, I didn't do it right."  I won't say anyone can guarantee
bug-free code...but most bugs are self-inflicted.  And newcomers (as
well as all too many outside of games) see this and think "That's how
*real* programmers do it."

Well, there are a few "programming gods" who can work that way and get
it perfect.  There are also several thousand who aren't anywhere near
that good, but think they are.  Myself, I'll settle for code I can
read, thanks.

--Dave Rickey

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list