Design by Contract was first explored by Bertrant Meyer. He has invented a language named Eiffel in which contracts are explicitly stated for each method, and checked at each invocation. The contracts define preconditions, postconditions and invariants.
Design by Contract advocates writing the conditions and invariants first. Constraints can be written by annotations and enforced by a test suite.
The contract will be applied on the method and will normally contain the following pieces of information:
In rare cases performance guarantees are also part of the contract.
When applying design by contract a client should not try to verify that the contract conditions are satisfied. Instead the service will throw an exception and the client should be able to cope with that exception.
Design by contract will facilitate code reuse since the contract documents each piece of the code fully; e.g. the contract for a method can be regarded as a form of software documentation for the behavior of that module.