David Delony said:
Since the best way to learn how to program well is to read other
people's programs, which open source projects written in C stand out
as examples of well-written code?
It really isn't.
You should read other people's code of course, but there are all sorts of
reasons why reading working "real" programs won't tell you how to do a good
job yourself.
Think of a program as a building. Not a house. A functional building like a
factory that has to be built to budget and always has some special
requirements. Normally the procedure will be to buy in a lot of pre-formed
components - walls, stairs, roofs and so on. Then they are bolted together.
But because our factory is a real building housing a unique process, some
will have to be modified. You might need air flow towards the "dirty end",
so you've got to seal all the windows, take out all the firedoors, and put
in fans, for instance. Then because you've taken out the firedoors you might
need to put in a sprinkler system to comply with regulations. So we end up
with a lot of standard components, modified components, and some custom
built components, all welded together and then put under a facade to make up
a finshed building.
To really understand how to make a building like that youself, it is best to
go to the standard components. The finished building will often confuse.
Code, such as mass of defines to make a file compile under both Windows and
Unix, can be well-written in the sense that it achieves the goal, whilst
being very hard for a human to understand and not a good basis for other
code, often not even a good basis for another cross-platform program. Often
there will be bits which have been micro-optimised, or hacked to get round
some late-breaking design problem.
"The only thing that is worse than pseudo-code [in academic texts] is real
code". I don't actually agree with this, but it has a point. Real code can
be hard to read, unless it is deliberately written for the purposes of
instruction.