- routine preconditions
- routine postconditions
- class invariants
- check instructions (like assert)
- loop invariants
The idea behind Design by Contract is software designers should define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with preconditions, postconditions and invariants. Now many claim that using ‘Types’ in your programs leads to ‘more correct programs’ (via the Howard Curry Correspondence). From what I can see – even the most advanced use of Dependent Typing in Idris and Scala is limited to Sum Types and list lengths (correct me if I’m wrong). By contrast – the power of ‘Design By Contract’ in establishing the correctness of my program is more general and more powerful. (Albeit not necessarily at compile-time – but at test time). I can for example establish in my banking program that all deposits are positive, and all reported account balances are positive. The point being – types have a fascinating future of possibilities, and are enormously powerful and compile time – but right now their practical application seems limited. My question is: is design by contract of more general application than using theorems from types to reason about the correctness of my program at present? (Or are we just talking about two different things)
Asked By : hawkeye
Answered By : Uday Reddy
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/19135