Views on Design By Contract

99 views
Skip to first unread message

yu wen ng

unread,
Jul 23, 2013, 7:24:06 PM7/23/13
to cof...@googlegroups.com

I am currently reading up to understand more about Design By contract to write a report and i found this tool interestesting. I will also like to gather more information and views from people from this forum

I will really appreciate people/owners to share their views and experience with Design By Contract with me. 
Disadvantages or advantages are welcome.

As from what i know, it is to write contracts (Invariants, Pre and Post conditions) to ensure that the codes can be maintain orderly. It will also guarantees that bugs will be prevented by a well defined mechanism based on checks and balances

But wouldnt this implicated the software performance? As there are additional checks between each method calls.

Thank you in Advnace :D


Jean-Simon LaRochelle

unread,
May 14, 2015, 1:51:22 PM5/14/15
to cof...@googlegroups.com
Design by Contract does not have any disadvantages if it is well supported by the language or librairies. By well supported I mean:

1) The code (contract checking) for the preconsitions, postconditions and invariant  is isolated from the "business" code.
2) The contract checking code does not add any execution overhead in a final release of the software

In theory Cofoja satisfies both criteria. In practice, using Cofoja in Netbeans and ANT (our Ant scripts are standardized and use macro....) was so difficult that I gave up. 

However Design By Contract is such a great methodology that I have used it with the build-in assert keyword in both Java and C#. Using asserts satisfies (2) but not (1) but works "out of the box" without having to make complex modifications to the ANT script or IDE. In the case of Java  in fact no modifications need to be made to any of these. 
I sure wish someone would come out with a language that support DBC out of the box.

I think I will give COFOJA another try....

JS
Reply all
Reply to author
Forward
0 new messages