3 ms·
Eiffel's take on inheritance might be an answer to its 'perils': https://www.eiffel.com/values/design-by-contract/introduction/ https://www.eiffel.com/values/de
by yawaramin 8y ago
Eiffel's take on inheritance might be an answer to its 'perils': https://www.eiffel.com/values/design-by-contract/introduction/ https://www.eiffel.com/values/design-by-contract/introductio...
Here's the crucial part: in Eiffel, methods can have preconditions and postconditions, and overridden methods in subclasses must honour those conditions in specific ways:
> The principle of subcontracting follows from these observations: a redefined version of r may keep or weaken the precondition; it may keep or strengthen the postcondition. Strengthening the precondition, or weakening the postcondition, would be a case of “dishonest subcontracting” and could lead to disaster. The Eiffel language rules for assertion redefinition support the principle of subcontracting.
In a sense, languages which support inheritance might not actually be doing it correctly if they don't support these rules of 'subcontracting'.