Re: Question on LSP



"Daniel T." <postmaster@xxxxxxxxxxx> wrote in message
news:postmaster-772BB0.13224118042006@xxxxxxxxxxxxxxxxxxxxxxxxxx

In article <e22p23$1o7$1@xxxxxxxxxxxxx>, "S Perryman" <a@xxxxx> wrote:

"Daniel T." <postmaster@xxxxxxxxxxx> wrote in message
news:postmaster-3417BD.08305818042006@xxxxxxxxxxxxxxxxxxxxxxxxxx

Even if they put the try catch block in, the programs behavior will
*still* change, which is against the principles of LSP.

The programs behaviour will indeed change, because it was *incorrect* .

The List contract states (albeit rather poorly) that
UnsupportedOperationException may be thrown if the add op is invoked
on a List instance. The component user is therefore obliged to deal with
this fact.

Even users who do deal with the exception will have the behavior of
their programs change. That is so obvious, I'm surprised I have to
mention it.

If the user has been dealing with the exception from the outset, their
behaviour
has not changed at all (obviously) . It is correct when a List instance
raises the
exception, and correct when the instance does not. The behaviour conforms to
the
List contract.

Which is in contrast to the behaviour user who ignores the contract as
defined
by List, and does not deal with the exception. It is correct when a List
instance
does not raise the exception, and *incorrect* when the instance does.

The only obvious thing here is that defective s/w has to change its
behaviour.
Specifically, change its behaviour to be *correct* .

And the fact remains that this example is not a case of DbC holding while
Liskov/
Wing subtyping does not. It is an example of a user completely ignoring a
component contract, and then complaining when their ignorance results in
their
s/w (and not the component suppliers' ) becoming defective.


Regards,
Steven Perryman


.



Relevant Pages

  • DbC & TDD: Fizzing Fusion or Flat Fizzle? [2/2]
    ... an invariant is a general clause which ... information: the contract. ... The short form retains headers and assertions of exported features, ... exception handling -- handling abnormal cases. ...
    (comp.object)
  • Re: Help with year to month converson
    ... We havent yet had an occasion where there was an exception to ... to perform these calculations for me. ... I do have the start date, end date and total amount, and if the contract is ...
    (microsoft.public.access.gettingstarted)
  • Re: Using exceptions for early exit
    ... Maybe it's an overly painful contract then. ... >> Notice that with your unchecked exception algorithm that as soon as ... > void run; ... When chosing between a language with goto statements versus a language ...
    (comp.lang.java.programmer)
  • Re: What is an interface?
    ... > I still can't see what 'Runnable' gets you if it has no connection to ... Throwing an exception would be the sensible thing to do. ... out at compile time). ... it's just the contract idea. ...
    (comp.lang.java.programmer)
  • Re: Question on LSP
    ... SP> If the user has been dealing with the exception from the outset, ... SP>to the List contract. ... does a UnsupportedOperationException being thrown at point Y constitute ... subtype in place of a supertype. ...
    (comp.object)