CSC/ECE 517 Fall 2007/wiki3 2 bp

From Expertiza_Wiki
Revision as of 02:07, 12 November 2007 by Bmparees (talk | contribs)
Jump to navigation Jump to search

Programming by Contract

Purpose of this Wiki

This wiki page was created to address the following assignment:

In class, we had some difficulty coming up with good examples of programming by contract. Find some concise ones that illustrate the principle well, and are accessible to a general audience of programmers.

Overview

Programming by Contract originated with the Eiffel programming language. <ref> http://en.wikipedia.org/wiki/Design_by_contract</ref> It is a technique for designing software systems in such a way that all the pieces meet certain obligations to each other. If all obligations are correctly met, then the system as a whole will work correctly.

The obligations are defined in terms of suppliers (components that offer a method that can be invoked) and clients (components that invoke those methods). Suppliers must provide the service they are contracted to provide (known as a postcondition), and clients must respect the restrictions of the supplier (known as a precondition).

Examples

Real World Examples

Examples in this section are based around real world metaphors and do not rely on programming specific concepts such as classes, methods, etc.


Programming Based Examples

Examples in this section use terms which are more specific to programming, defining themselves in terms of classes, methods, and pseudocode. In keeping with the goal of having the examples be accessible to the general audience of programmers, examples using exotic/rare programming languages were excluded.


References

The examples above were drawn from the following sources: