I need to know if a redefined function in Eiffel can define its own assertions.
Asked
Active
Viewed 156 times
0
-
So you can't answer this question *after* having read about "design by contract"? Also it's unclear what "its own" assertions actually means. An example would be helpful. – U. Windl May 24 '21 at 18:00
1 Answers
5
Yes it can. But a redefined feature can only weaken its parent's precondition and strengthen its postcondition. To make it clearer you are forced to declare your precondition as a require else
in the redefined feature, and declare the postcondition as an ensure then
to make it clear that you are weakening/strengthening the corresponding assertion.
See the documentation site for a more in depth explanation.

Zoran Simic
- 10,293
- 6
- 33
- 35