Version 8 of How one learns to write better code

Updated 2002-02-28 16:08:09

A correspondent asked this. As I haven't the time now to answer him, I'll invite The Collective to do so.

[Quality of C-coded Tcl/Tk source.]

[Read good code.]

[Paramount importance of engineering review.]

[Example rewrite sessions.]

[chat?]


While learning to write good (better) code is a life-long journey, I think that there are three significant events in my career.

First, while employed in a Fortune 100 company, my group all took training in structured design (the "Yourdon" methodology, FWIW). That taught me the importance of loose coupling, well defined interfaces, and code reviews.

Second, I had the good fortune to read "Software Tools" by Kernighan & Plauger [L1 ]. I regard this as possibly the single best source on software engineering. (Bryan Oakley sez a big AMEN to that. It had a bigger impact on my coding skills than any thing else, by a long shot)

Third, as part of my MS studies in Computer Science, I took a course on "provably correct systems". While I initially thought that the couse would be interesting, though abstract and useless, it may be the single course that has most influenced my coding style.

That said, I endorse reading good code and code reviews as important parts of the on-going process of learning to write better code.

                                         -- [CLN]

Arjen Markus I have read a fair number of books, for instance Kernighan and Pike's The Practice of Programming (which I highly recommend), but the only way (as far as I can see) to improve the quality of the code you write is: keep it simple, keep it clear, do not try to be smart, and above all: learn from other people's coding habits.

Oh, and be keen on learning a better style!


Mark Roseman Having people write thorough automated tests for their code (using e.g. tcltest) also results in a dramatic increase in code quality. It forces thinking about error handling, corner cases, appropriate factoring and modularity, and maintainability.


[Reference to style sheet.]