Efficient coding considered harmful?

John A. Ebersold vfm6066 at dsacg3.UUCP
Tue Nov 8 04:16:40 AEST 1988


I have been following this for some time.

My two cents...

Balance all coding "tricks" against the need to produce readable and thus
maintainable code.  

Get the code working properly first, make sure it can be read and understood
by programmers less talented than yourself.

Comment liberally, (the l-word and oh nooo the c-word), however do not
re-state the obvious, e.g,

#define EOF 0

/*
** Read until end of file  (silly comment)
*/
while (fread != EOF)

(Don't laugh, I've seen it done).

Misleading comments are worse than no comments at all.  If your algorithm
requires five times as many lines of as the code - so be it.  You may be
immersed in it now, but try and remember what is going on six months from
now - pity on the poor maintainer.

The most important comments are those that give the BIG PICTURE, followed by
those that show how the parts fit into the whole.

Lastly, if it is too slow, profile it and fix the slow parts in a readable
manner.   Humbley (is that a word?).



More information about the Comp.lang.c mailing list