Betrand Meyer defined something similar, but more formally: 1. An overriding method may [only] weaken the precondition. This means that the overriding precondition should be logically "or-ed" with the overridden precondition. 2. An overriding method may [only] strengthen the postcondition. This means that the overriding postcondition should be logically "and-ed" with the overridden postcondition. 3. A derived class invariant should be logically "and-ed" with its base class invariant. In essence, implementations may relax the requirements on its inputs and can be stricter on the conditions of its outputs. Jon Postel gave a general guideline, Meyer applied it to design by contract, the principle holds true for interoperable design.
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.