Next / Previous / Contents / Shipman's homepage

2. The contract-based approach to program construction

In the humorous lexicon The computer contradictionary, we find this definition:

 

Interface: An arbitrary line of demarcation set up in order to apportion the blame for malfunctions.

 
 -- Stan Kelly-Bootle, The Computer Contradictionary, MIT Press, 2nd Ed., 1995, ISBN 978-0262611121.

Interfaces occur at two levels in a software design.

Every interface is, in effect, a contract that divides responsibility between the provider of a service and the user of that service.

In effect, this contract says:

If the user agrees to certain requirements, the service guarantees to function correctly.

To apply this approach to software construction, for each interface, we must describe the interface, and the semantics of the provided service, in a sufficiently rigorous way that both are unambiguously defined.

Our ideal here is scrutable connectivity to first principles.

2.1. Skills you will need

  • This method isn't for novice programmers. Novices are inclined to treat the formal methods as “unnecessary extra work.” It is necessary to have a certain minimal amount of experience with real-world software, tools that must survive ignorant or malicious users, to understand that getting the design right in the first place really is the shortest path to a robust solution.

  • The methods require a reasonable familiarity with discrete math. Here's the catalog description of Math 221 at New Mexico Tech, Formal Logic and Discrete Mathematics, which is a prerequisite for the Zero-defect Software Design course:

    Analytical reasoning and critical thinking skills. Induction and recursion. Mathematical proofs. Propositional calculus and predicate calculus. Discrete and combinatorial mathematics: sets, functions, relations, trees, graphs, permutations, and combinations.

  • Clear, concise writing is central to the design process. The author starts each new design by writing a draft specification. However, the coding process is no less a writing task, and requires careful work in naming and describing algorithms and data structures at every step of the way.

     

    Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer.

     
     -- Edsger J. Dijkstra, Selected writings on computing: a personal perspective, Springer-Verlag, 1982, pp. 129-131, ISBN 0-387-90652-5.