Chapter 2. Subversion’s Delta Editor: Interface As Ontology
Examples of beautiful code tend to be local solutions to well-bounded, easily comprehensible problems, such as Duff’s Device (http://en.wikipedia.org/wiki/Duff's_device) or rsync’s rolling checksum algorithm (http://en.wikipedia.org/wiki/Rsync#Algorithm). This is not because small, simple solutions are the only beautiful kind, but because appreciating complex code requires more context than can be given on the back of a napkin.
Here, with the luxury of several pages to work in, I’d like to talk
about a larger sort of beauty—not necessarily the kind that would strike a
passing reader immediately, but the kind that programmers who work with
the code on a regular basis would come to appreciate as they accumulate
experience with the problem domain. My example is not an algorithm, but an
interface: the programming interface used by the open source version
control system Subversion (http://subversion.tigris.org) to express the difference
between two directory trees, which is also the interface used to transform
one tree into the other. In Subversion, its formal name is the C type
svn_delta_editor_t, but it is known
colloquially as the delta editor.
Subversion’s delta editor demonstrates the properties that programmers look for in good design. It breaks down the problem along boundaries so natural that anyone designing a new feature for Subversion can easily tell when to call each function, and for what purpose. It ...