Re: A question about substitution principle
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sun, 25 Sep 2005 13:26:03 +0200
On Sun, 25 Sep 2005 10:09:40 GMT, Tony Johansson wrote:
> Figure 1: operation top element from a stack using weak contract
> Precondition: true
> Postcondition: If not empy
> then result = top element from stack
> else throw EmptyException
>
> Figure 2: operation top element from a stack using strong contract
> Precondition: true
> Postcondition: result = top element from stack
>
> The substitution principle and Bartrand Mayer say that in particular it does
> not make Figure 1 define a subtype of figure 2.
> Cerainly, the precondition of Figure 1 is weaker than that of Figure 2.
It is not weaker, it is equal: true <=> true
> The
> postcondition of Figure 1, however, is not stronger than that of Figure 2,
> since a thrown exception satisfies the former but not the latter.
No, it is. The postcondition of figure 1 is: A V B, where
A = (result = top element...)
B = (exception thrown)
The postcondition of figure 2 is A.
Clearly A => A V B
> Now to my question: I don't understand what it means with "The postcondition
> of Figure 1, however, is not stronger than that of Figure 2, since a thrown
> exception satisfies the former but not the latter."?
"Stronger or equal" on conditions is logical implication =>. The equality
relation is logical equivalence <=>.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: A question about substitution principle
- From: Tony Johansson
- Re: A question about substitution principle
- References:
- A question about substitution principle
- From: Tony Johansson
- A question about substitution principle
- Prev by Date: Interface complexity problem in game
- Next by Date: Re: A question about substitution principle
- Previous by thread: A question about substitution principle
- Next by thread: Re: A question about substitution principle
- Index(es):
Relevant Pages
|