Home > Uncategorised > Design By Contract

Design By Contract

January 11th, 2005 Leave a comment Go to comments

Now here is a seemingly good idea.

Originating in the language Eifel, Design by Contract means that with each function you specify a series of predicates which dictate a class’s (or procedures) pre- and post-execution states. E.g. for a function which guarantees that an integer parameter is the absolute value of a number, you specify the pre-condition as being the input number is an integer (i.e. param.IsInteger()) and the post-condition as the return value will always be greater than or equal to zero (i.e. return >= 0)

Before and after the code executes, the contract between the calling procedure (the client) and the procedure is checked, and if either side breaks the contract an error is raised as the program has a bug.

It’s probably best if you read more about it – I probably haven’t explained it very well!

Wonderfully though, Microsoft have taken notice of this technique and are researching a language called “Spec#” which works along side the next release of Visual Studio .Net and the .Net framework.

Categories: Uncategorised Tags:
  1. No comments yet.
  1. No trackbacks yet.