Prev Up Next
Go backward to Selected lecture notes and example code
Go up to Resources
Go forward to CORBA

Literate programming

The code we discussed earlier for the matrix vector product example is not documented, except for a few comments in the code. Here is another version, which is essentially the same functionally as the omniORB version that uses the naming services. The main difference is in the way the program is written and documented in the "literate programming style," as briefly discussed in the document itself. Both documentation and code are prepared in a single source file, called a Nuweb file. Running the Nuweb processor on this file produces as output both a LaTeX document file and the code file(s) for input to a compiler (and any other files prepared in the document such as makefiles or sample input files). The main idea behind literate programming is that many programs are more often read by humans than executed, so it's vitally important to make them readable and to ensure that documentation remains consistent with the code. Another key idea is that the goal of presenting programs in segments arranged in a logical order (rather than the order required by the compiler) actually helps the programmer to design good programs in the first place. So one should not first write the code and then start reorganizing it for purposes of documentation; instead it's much better to code and document at the same time.

There is further information on Nuweb in the Other Languages and Tools section.
 

Prev Up Next