Wednesday, February 4, 2009

Why is Design by Contract not common practice in Software Enineering

Concerned with a lot of source code reviews over the last years, I have recognized that Design by Contract is not a common practice in Software Engineering. Nearly all C++, Visual Basic, Java and C# source code I saw was designed and written without applying Design by Contract. Thinking about the reasons for programmers not to use Design by Contract I made a list with questions they may have:
  • What is Design by Contract?
  • What are the benefits of Design by Contract?
  • Do I need to use Eiffel as my programming language to apply Design by Contract?
  • Do I have to spend a lot of effort for Design by Contract?
  • In which situations should I use Design by Contract?
  • Does Design by Contract conflict with other design and implementation techniques like TDD and DDD?
If you have no or wrong answers for these questions you will probably not use Design by Contract in your day to day programming work. I will try to answer these questions in a series of articles and hope it will convince more programmers that Design by Contract is an elegant technique to improve software quality.

3 comments:

Anonymous said...
This comment has been removed by the author.
Anonymous said...

I came across your blog while looking for more examples of how to use design by contract in practice. I read Mitchell and McKim's book (Design by Contract by Example) and came away rather disappointed, as they mainly seemed to explain how to apply it to container-style classes. Perhaps when you write your articles you could give, or give links to, some real life examples of DbC applied to other situations, and some examples of what (if anything) it is not good for?

Sven said...

Michael,
I'm in the middle of writing some stuff about DbC. Thanks for the comment and I will try to give some meaningful examples. Real world examples tend to be be quite long and contain a lot of details. This may be boring for some readers. I use DbC a lot in real life and it helps a lot :-) I