CTEC1335/2008F Programming by Contract (PBC) - Introduction ============================================ [also known as "Design by Contract" (DBC)] - a way to design programs - two functions enter into a "contract", where each has rights and responsibilities - the function doing the calling, the "caller", has the responsibility of passing valid data (arguments/parameters) to the function it calls, the "callee" - the caller must check these "preconditions" using if statements or assertions before calling the callee - the callee has the right to expect valid data from the caller - because of the contract, the callee does not have to check for valid inputs (arguments/parameters) - the callee has the responsibility of performing a service for the caller as designed, and the caller has a right to expect that this service will be performed correctly - the callee has the responsibility of validating its outputs (return values), using ifs or assertions before returning back to the caller - the caller has the right to expect valid return values from the callee - the caller is freed from having to check for valid return values from the callee (due to the contract) Link for more information: http://en.wikipedia.org/wiki/Design_by_contract