Sunday, September 24, 2006

 

Slashdot considers DbC for C++

A recent "Ask Slashdot" post starts with an anonymous reader looking for ways to use Design By Contract in C++. He wrote:
...I can imagine that a lot of the ideas from Eiffel can be applied there. I have looked around on the net and found a few articles talking about different ways of applying design by contract using assert statements and the like. I also found the dlib C++ library on SourceForge which, among other things, puts a design by contract face on a lot of API calls. So, there are obviously people doing it. What is everyone's experience with Design by Contract in C++? What tools are there that help make it a workable system? Lastly, are there any pitfalls to taking this approach in C++?
The discussion that followed contained plenty of suggestions (some informed, some misinformed, some humorous - this is Slashdot after all).

Brian Heilig pointed out five ways in which Eiffel's "genuine" DbC worked better than simulations in C++. Briefly, these were:
Coryoth agreed, concluding that
Eiffel is actually an extremely elegant language with powerful DbC built into at the core. If DbC is something that's important to you Eiffel probably is your best choice.

Comments:
My brother wrote a lot of time ago, when we did not have access to an Eiffel compiler and were forced to use C anyway a library to have some DbC features called BetterC

It provides several DbC features (different kinds of assertion, eiffel syntax macros, eiffel like exceptions with retry, tracing, enable different levels of assertion checking), while skipping some of the hard ones (assertion inheritance in C++, loop variants).

Certainly it is not as good as the real thing, but it is a lot better than plain C/C++. I can't live without it when I need/I am forced to to use C, it certainly has saved my day lots of times.
 
Bertrand Meyer made the funniest post on this subject on the Yahoo! Eiffel Software group. Check it out.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?