What is design by contract? Explain the assertion construct?

Questions by prhema   answers by prhema

Showing Answers 1 - 3 of 3 Answers

In every class or method, there will be a calling function and a called function.
When ever a function(calling function) calls another function(called function), the called function is expected to reply by executing its method.
Design by contract is such a technique by which an well mannered and defined interface can be developed between the calling and called functions.7
In this manner, the developer will have an excellent chance of understanding the function(method) and the functions pre and post conditions and also it provides documentation to the caller(calling function).
Java uses the assertion construct(assert statement) to implement pre and post conditions.Design by contract is also called as programming by contract and is also supported by exception handling in Java.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions