Wednesday, April 12, 2006

Design by Contract

Design by Contract was propounded by Bertrand Meyer at program language Eiffel. It is an advanced assert which a programmer can write the condition on functions and the methods. The contract consists of the following conditions:

  • Pre-conditions.
  • Post-conditions.
  • Consistency checks.

If a case does not meet these conditions, an exception is thrown. A developer can find problems of the program easily by an exception. And he always keeps cool because he can write down the code's spec on the source code.

"Design by Contract" is tried in many program languages. We can use it in C++? We can implement Pre-conditions with assert(). Post-conditions and Consistency checks are difficult in C++. We can get many sample codes from the internet because many programers try it in C++.

No comments: