REVIEW - Design by Contract, by Example


Design by Contract, by Example


Richard Mitchell, Jim McKim



Addison-Wesley Professional (2002)




Francis Glassborow


February 2002



I first came across Design by Contract when reading about Eiffel. Support for DbC is one of the main features of that language. The idea being that each function should start with a set or pre-conditions (things that had to be true for the function call to go ahead) and end with a set of post-conditions, things to be enforced before successful return (failure of either group causes failure). It is very difficult to bolt DbC support onto a language. Of course when you understand the ideas, you can implement them manually. But if you understand OOP you can do it manually in C or even, if you are a real masochist, in assembler. But C++, Smalltalk etc. provide you the tools to do OOP without too much pain and tedious repetition.

In the same way Eiffel provides the tools for DbC. I believe there is a tool that allows you to bolt on a kind of DbC to Java (iContract,

The authors claim to have distilled DbC down to six principles, listed on pages 42-3 (and discussed in the preceding text.) The problem is that to get much value from this book you need to have suitable software tools. In the light of this, I decided to tell readers that this book exists and invite someone to volunteer to do a complete review. Of course a precondition for volunteering is that you have tools that provide adequate support for DbC (either Eiffel or Java + iContract). I would also like someone to volunteer to have a look at iContract and write about it for our Members' Experiences column. Lastly, if it can be done as a bolt on to Java, can it be done for C++?Professional Development

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept All Cookies" you agree ACCU can store cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

By clicking "Share IP Address" you agree ACCU can forward your IP address to third-party sites to enhance the information presented on the site, and that these sites may store cookies on your device.