Freigeben über


Design by contract in real life

Today I got a sweet reminder on developing with contracts when I read this (in Swedish). I always get a warm feeling in my body when I think about design by contract (which I have earlier mentioned here). A summary of the Swedish post is that Microsoft Research is working on one language called Spec# and one extension for any language called CodeContract. I first learned about design by contract in University when we used Eiffel and I like the basic idea. Design by contract is also a very powerful tool to make code reviews effective since it isolates each method making it possible to review a single method without having to look at how the method is used. I once did this in a C project using precondition and postcondition macros that basically where asserts enabled in both release and debug builds. So even without fancy tools and support in the language you can still enjoy the benefits from contract programming.

Comments

  • Anonymous
    April 25, 2009
    Thanks for this info. I've been a great fan of DbC for many years. I'm glad to see it promoted by MS, both mentally and practically.