|
If you're new to Unix, these principles are worth some meditation. Software-engineering
texts recommend most of them; but most other operating systems lack the right tools and
traditions to turn them into practice, so most programmers can't apply them with any
consistency. They come to accept blunt tools, bad designs, overwork, and bloated code as
normal 鈥 and then wonder what Unix fans are so annoyed about.
Rule of Modularity: Write simple parts connected by clean
interfaces.
As Brian Kernignan once observed, 鈥淐ontrolling complexity is the essence of computer
programming.鈥 Debugging dominates development time, and getting a working system out
the door is usually less a result of brilliant design than it is of managing not to trip over your
own feet too many times.
Assemblers, compilers, flowcharting, procedural programming, structured programming,
鈥渁rtificial intelligence鈥, fourth-generation languages, object orientation, and software-
development methodologies without number have been touted and sold as a cure for this
problem. All have failed, if only because they 鈥榮ucceeded鈥 by escalating the normal level of
program complexity to the point where (once again) human brains could barely cope. As
Fred Brooks famously observed [Brooks], there is no silver bullet.
The only way to write complex software that won't fall on its face is to hold its global
complexity down 鈥 to build it out of simple parts connected by well-defined interfaces, so
that most problems are local and you can have some hope of upgrading a part without
breaking the whole.
Rule of Composition: Design programs to be connected with
other programs.
It's hard to avoid programming overcomplicated monoliths if none of your programs can talk
to each other.
Unix tradition puts a lot of emphasis on writing programs that read and write simple, textual,
stream-oriented, device-independent formats. Under classic Unix, as many programs as
possible are written as simple filters, which take a simple text stream on input and process it
into another simple text stream on output.
|