comp.lang.ada
 help / color / mirror / Atom feed
From: Bertrand Meyer <bertrand@eiffel.com>
Subject: Re: Papers on the Ariane-5 crash and Design by Contract
Date: 1997/03/22
Date: 1997-03-22T00:00:00+00:00	[thread overview]
Message-ID: <33343EE3.7DE14518@eiffel.com> (raw)
In-Reply-To: tz8ohcjv7cc.fsf@aimnet.com


Is it ever possible  to have a technical discussion without
resorting to insults? Jon S. Anthony finds it productive to write,
about one of my earlier messages:

> Do you have any idea how ridiculous this sort of statement makes you
> look???

He adds for good measure that my comments are

> extremely disappointing and make [me] look [again!] ridiculous.

and that I am

> just plain a) wrong or b) - well it doesn't take a genius to fill in
> the obvious answer to this option.

It is this type of gratuitous attack that empoverishes Usenet and has
the potential to destroy it. When people who know what they are talking
about, and could contribute usefully to the debate, see this kind of
absurdity, they refrain from participating. Everyone loses.

I assume Mr. Anthony's hope is that by making sufficiently outrageous
statements he'll win by causing others either to lose their temper
or to shut up in disgust. For me the latter will probably happen,
but not yet. So let's see what he has to contribute.
 
In response to my matter-of-fact statement that

!!! The designers of these languages [i.e. Ada (83 or 95) and Java]
!!! have explicitly rejected the inclusion of assertions

he writes that

> Ada _has_ assertions.  Their form is not of the same syntactical look
> as Eiffel's.  So what?  They take the form of constraints, in
> particular (wrt to the case at hand) subtype constraints  
 
OK. Ada has assertions. Great news! I have read a lot about Ada but
must have missed them. So let's see what their application would be
to a typical example of Design by Contract.

Take a class PERSON in a system for genealogical or demographical
analysis. Here are some of the logical properties to be documented
and enforced:

        - A person is married if and only if he or she has a spouse.

        - The spouse of a person's spouse is that person.

        - You cannot marry someone who is already married.

        - The gender of a person's spouse is not the same as that
	  person's gender. (Note that this is consistent with the
	  observation that we need at least three values for the
	  gender: Male, Female and  Unknown. We may be talking
	  about processing a database with incomplete
	  information.)

I think we can accept these rules as part of the specification and stay
away from facile jokes and individual opinions about the underlying
topics (polygamy, same-sex marriages etc.). Just consider that this
is a genealogical database for 19-th century England.

Here is a quickly written sketch in Eiffel. I don't guarantee the
exactness of the details since this is a 5-minute design, but the
ideas should be clear.

    class
        PERSON

    feature -- Access

        gender: ...

        status: ...

        married: BOOLEAN
                -- Is person married?

    feature -- Element change

        marry (other: PERSON) is
                -- Get married to `other' .
            require
                available: not married
                other_exists: other /= Void
                other_not_married: not other.married
                different_gender: gender /= other.gender
            do
                ...
            ensure
                married: married
                married_to_other: spouse = other
            end

    ... Other features ...

    invariant

        married_iff_has_spouse: married = (spouse /= Void)
        married_to_spouse: married implies (spouse.spouse = Current)
        married_to_other_sex: married implies (gender /= spouse.gender)

    end

        (Some comments come up immediately, e.g. the assertions
	preclude a married couple with two "unknown" genders,
	suggesting that perhaps
        instead of expressions of the form `gender1 /= gender2'
        we should have a function same_gender (s1, s2).
        Or perhaps not. But this is precisely where the ideas of
        Design by Contract as implemented in Eiffel help you: they force
        you to ask the tough questions at the right time
	- class design -, not let a down-the-line implementer,
	writing in a lower-level programming language devoid of
	those concepts, make the tough decisions, rightly or not,
	consciously or not, and without an automatic feedback
	into the analysis and design.)

        (Also, `not married' is probably too weak; we may need a
        function `available_for_marriage' which is defined in terms of
        the status, e.g. if status can be Single, Divorced, Now_married
        and Dead, and we have an invariant clause stating that
        `married = (status = Now_married)', then
	`available_for_marriage' will mean Single or Divorced.
	Same comment as before: it's precisely by writing and
	refining assertions that we can get things right when it's
	still time. That's the idea in Eiffel. The above class sketch
	is only a first iteration.)

I have purposely not filled the types for `status' and `gender',
and the trivial properties that can be expressed by using enumeration
types a la Pascal-Ada and range constraints, for example
that `status' and `gender' can only take certain specified values.
These are easy to add.

Now if Ada has assertions, how would you express the above properties?

        (For anyone not familiar with Design by Contract: we are not
        talking about testing for abnormal cases, as in
        `if other.married then ... Report error ...',
        nor even about Algol W/C/C++ `assert' instructions, as in
        `assert not other.married'. Instead, we are interested in
        associating with every software element - class or routine -
        a precise specification, or "contract", describing
        its obligations and benefits. The contract will serve as
        help in the analysis-design-implementation process (as briefly
        mentioned above), as documentation of the final software, as
        aid in debugging - by turning on run-time assertion monitoring
        in Eiffel environments -, as safeguard in using inheritance, as
        a basis for exception handling etc.)

        (The precondition of a routine, introduced by `require', states
        what must be true for the routine to be applicable; for example
        don't apply `marry' unless the   reference `other' denoting
        the intended spouse is non-void, i.e. is attached to some
	object. The postcondition of a routine, introduced by
	`ensure', states the goals to be achieved by the routine;
	for example one of the results of `marry' is to make the
	boolean property `married' true.
        The invariant of a class expresses properties that
	will be satisfied at object creation time, and maintained
	by all routines of the class, e.g. a person is married if
	and only if he or she has a spouse - which
        places constraints on what such routines as `marry',
	`divorce' etc. can do; these constraints come on top of
	the routine's own specific constraints, as expressed by
	its precondition and postcondition.)


 
-- 
Bertrand Meyer, President, ISE Inc., Santa Barbara (California)
805-685-1006, fax 805-685-6869, <bertrand@eiffel.com> -
ftp://ftp.eiffel.com
Visit our Web page: http://www.eiffel.com
	(including instructions to download Eiffel 4 for Windows)




  parent reply	other threads:[~1997-03-22  0:00 UTC|newest]

Thread overview: 254+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-15  0:00 Papers on the Ariane-5 crash and Design by Contract Bertrand Meyer
1997-03-18  0:00 ` Ariane-5: can you clarify? (Re: Please do not start a language war) Jon S Anthony
     [not found] ` <tz8ohcjv7cc.fsf@aimnet.com>
1997-03-16  0:00   ` Papers on the Ariane-5 crash and Design by Contract Robert Dewar
1997-03-17  0:00     ` Please do not start a language war (was " Jean-Marc Jezequel
1997-03-18  0:00       ` Richard Irvine
     [not found]       ` <tz8913l930b.fsf_-_@aimnet.com>
1997-03-18  0:00         ` Ariane-5: can you clarify? (Re: Please do not start a language war) Gavin Collings
1997-03-18  0:00         ` Ariane-5: can you clarify? (Re: Please do not start a language war Roedy Green
1997-03-18  0:00       ` Please do not start a language war (was Re: Papers on the Ariane-5 crash and Design by Contract Ken Garlington
     [not found]         ` <199703190839.JAA02652@stormbringer.irisa.fr>
1997-03-19  0:00           ` Ken Garlington
1997-03-20  0:00             ` Roger T.
1997-03-21  0:00               ` Jean-Marc Jezequel
1997-03-24  0:00                 ` Ken Garlington
1997-03-21  0:00               ` Ken Garlington
1997-03-20  0:00             ` Robert S. White
1997-03-20  0:00               ` John L. Ahrens
1997-03-20  0:00               ` Martin Tom Brown
1997-03-21  0:00                 ` Wolfgang Gellerich
1997-03-21  0:00                 ` Robert S. White
1997-03-19  0:00         ` Jean-Marc Jezequel
1997-03-19  0:00           ` Richard Kaiser
1997-03-21  0:00           ` Ken Garlington
1997-03-21  0:00             ` Jean-Marc Jezequel
1997-03-25  0:00               ` Ken Garlington
1997-03-26  0:00                 ` Trust but verify " Robert S. White
1997-03-25  0:00                   ` Bertrand Meyer
1997-03-26  0:00                     ` Robb Nebbe
1997-03-27  0:00                     ` Ken Garlington
1997-03-28  0:00                       ` Jeffrey W. Stulin
1997-03-31  0:00                         ` Ken Garlington
1997-03-28  0:00                       ` Karel Th�nissen
1997-03-28  0:00                         ` Ken Garlington
1997-04-07  0:00                           ` Jean-Marc Jezequel
1997-03-29  0:00                     ` the one and only real true kibo
1997-03-17  0:00   ` John McCabe
     [not found]     ` <tz8n2s1hrdc.fsf@aimnet.com>
1997-03-20  0:00       ` John McCabe
1997-03-20  0:00         ` Jean-Marc Jezequel
1997-03-20  0:00           ` John McCabe
1997-03-21  0:00             ` Niall Cooling
1997-03-21  0:00               ` Gavin Collings
1997-03-27  0:00                 ` Joachim Durchholz
1997-04-03  0:00                   ` Gavin Collings
1997-04-03  0:00                     ` Ken Garlington
1997-04-04  0:00                       ` Derek Clarke
1997-04-04  0:00                     ` Derek Clarke
1997-04-06  0:00                       ` Robert Dewar
1997-04-07  0:00                         ` Ken Garlington
1997-04-09  0:00                           ` Gavin Collings
1997-04-03  0:00                   ` Robert I. Eachus
1997-04-04  0:00                     ` Chris Beer
1997-04-04  0:00                     ` Derek Clarke
1997-04-04  0:00                   ` Ken Garlington
1997-04-04  0:00                     ` Robert Dewar
1997-04-03  0:00                 ` Robin Rosenberg
1997-03-24  0:00             ` Ken Garlington
1997-03-26  0:00           ` Thomas Beale
1997-03-26  0:00             ` Ken Garlington
1997-03-20  0:00       ` John McCabe
1997-03-21  0:00       ` "Paul E. Bennett"
1997-03-22  0:00     ` Nigel Tzeng
1997-03-23  0:00       ` John McCabe
1997-03-17  0:00   ` Paul Johnson
1997-03-17  0:00     ` Enrico Facchin - Sartori E.T.
1997-03-19  0:00       ` Anders Pytte
1997-03-18  0:00     ` Ken Garlington
1997-03-17  0:00   ` Bertrand Meyer
1997-03-18  0:00     ` John McCabe
1997-03-18  0:00       ` Ray McVay
1997-03-27  0:00         ` Robert Dewar
1997-03-29  0:00           ` the one and only real true kibo
1997-03-30  0:00             ` Nick Roberts
1997-04-06  0:00             ` Doctorb
1997-04-08  0:00         ` Ron Crocker
1997-04-11  0:00           ` Richard Riehle
1997-03-17  0:00   ` Alexander Anderson
1997-03-17  0:00   ` Nick Leaton
1997-03-17  0:00     ` Richard Kaiser
     [not found]     ` <tz8g1xtzx9y.fsf@aimnet.com>
1997-03-18  0:00       ` Anders Pytte
1997-03-18  0:00         ` Jean-Marc Jezequel
1997-03-18  0:00           ` Anders Pytte
1997-03-19  0:00             ` Programming language fanaticism! Louis Bastarache
1997-03-20  0:00               ` Anders Pytte
1997-03-20  0:00             ` Papers on the Ariane-5 crash and Design by Contract Matt Kennel (Remove 'nospam' to reply)
1997-03-24  0:00             ` Joachim Durchholz
1997-03-24  0:00               ` Anders Pytte
1997-03-26  0:00                 ` Matt Kennel (Remove 'nospam' to reply)
1997-03-29  0:00                   ` Anders Pytte
1997-03-29  0:00                     ` Steve Furlong
1997-03-26  0:00                 ` Robert Dewar
1997-03-27  0:00                   ` the one and only real true kibo
1997-03-29  0:00                   ` the one and only real true kibo
1997-03-29  0:00                     ` Nick S Bensema
1997-03-30  0:00                       ` the one and only real true kibo
1997-03-18  0:00           ` Anders Pytte
1997-03-21  0:00           ` Ken Garlington
1997-03-21  0:00             ` Bertrand Meyer
1997-03-21  0:00               ` William Clodius
1997-03-21  0:00                 ` Bertrand Meyer
1997-03-23  0:00                   ` the one and only real true kibo
1997-03-23  0:00                   ` William Clodius
1997-03-22  0:00               ` Fergus Henderson
1997-03-22  0:00                 ` Bertrand Meyer
1997-03-23  0:00                   ` the one and only real true kibo
1997-03-23  0:00                     ` Anders Pytte
1997-03-24  0:00                   ` FUD (Re: Papers on the Ariane-5 crash and Design by Contract) Alexander Anderson
1997-03-24  0:00                   ` Alexander Anderson
1997-03-23  0:00               ` Papers on the Ariane-5 crash and Design by Contract Anders Pytte
     [not found]                 ` <3335BC24.13728473@eiffel.com>
1997-03-23  0:00                   ` Bertrand Meyer
1997-03-24  0:00                     ` Robert Dewar
1997-03-31  0:00                       ` Ken Garlington
1997-04-01  0:00                         ` Bertrand Meyer
1997-03-25  0:00                     ` Ken Garlington
1997-03-24  0:00                 ` Ken Garlington
1997-03-24  0:00                 ` the one and only real true kibo
1997-03-24  0:00               ` Ken Garlington
1997-03-26  0:00                 ` Robert Dewar
1997-03-26  0:00                   ` Ken Garlington
     [not found]                     ` <E7ox17.MKx@syd.csa.com.au>
1997-03-28  0:00                       ` Ken Garlington
1997-03-24  0:00               ` John Hogg
1997-03-18  0:00         ` Laurent Moussault
1997-03-18  0:00     ` Richard Kaiser
1997-03-18  0:00       ` Nick Leaton
1997-03-18  0:00         ` "Paul E. Bennett"
1997-03-19  0:00           ` Nick Leaton
1997-03-24  0:00           ` Joachim Durchholz
1997-03-25  0:00             ` Robert Dewar
1997-03-31  0:00               ` Jan Galkowski
1997-03-31  0:00               ` Joachim Durchholz
1997-04-02  0:00                 ` Robert Dewar
1997-04-03  0:00                   ` Martin Tom Brown
1997-04-04  0:00                   ` Derek Clarke
1997-04-04  0:00                   ` Jonathan Egre'
1997-04-06  0:00                     ` Robert Dewar
1997-04-06  0:00                       ` Nick Roberts
1997-03-31  0:00             ` Alexander Anderson
1997-04-01  0:00             ` Alexander Anderson
1997-04-02  0:00             ` Ken Garlington
1997-03-20  0:00         ` John the Hamster
1997-03-18  0:00     ` Richard Kaiser
1997-03-18  0:00       ` Jean-Marc Jezequel
1997-03-19  0:00         ` Ken Garlington
1997-03-18  0:00       ` Nick Leaton
1997-03-19  0:00         ` Richard Kaiser
1997-03-19  0:00           ` Fergus Henderson
1997-03-19  0:00           ` Jean-Marc Jezequel
1997-03-19  0:00             ` Richard Kaiser
1997-03-17  0:00   ` Robert I. Eachus
1997-03-17  0:00     ` Martin Tom Brown
1997-03-17  0:00   ` Please do not start a language war (was " Jon S Anthony
1997-03-18  0:00     ` Kent Tong
1997-03-20  0:00       ` Ranan Fraer
1997-03-18  0:00   ` Jon S Anthony
1997-03-19  0:00     ` Ron Forrester
1997-03-21  0:00       ` Ken Garlington
1997-03-22  0:00         ` Ron Forrester
1997-03-18  0:00   ` Jon S Anthony
1997-03-18  0:00   ` Robert I. Eachus
1997-03-18  0:00   ` Ulrich Windl
1997-03-18  0:00   ` Jon S Anthony
1997-03-18  0:00   ` Tarjei Jensen
1997-03-18  0:00   ` Ken Garlington
1997-03-19  0:00     ` Eric M. Boyd
1997-03-19  0:00       ` Jeffrey W. Stulin
     [not found]       ` <3345cd60.2092398@news.sydney.apana.org.au>
1997-04-03  0:00         ` Ariane-5 crash , Eiffel and Ada Jeffrey W. Stulin
1997-04-03  0:00         ` Nick Leaton
1997-04-08  0:00         ` AdaWorks
1997-03-18  0:00   ` Papers on the Ariane-5 crash and Design by Contract Jon S Anthony
1997-03-19  0:00   ` Karel Th�nissen
1997-03-19  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Karel Th�nissen
1997-03-19  0:00   ` Papers on the Ariane-5 crash and Design by Contract Nick Leaton
1997-03-19  0:00   ` Jon S Anthony
1997-03-20  0:00     ` Paul Johnson
1997-03-24  0:00       ` Ken Garlington
1997-03-24  0:00         ` Design by Contract in C++ (was Re: Papers on the Ariane-5 crash and Design by Contract) Anders Pytte
1997-03-20  0:00     ` Papers on the Ariane-5 crash and Design by Contract Jean-Marc Jezequel
1997-03-24  0:00       ` Ken Garlington
1997-03-19  0:00   ` Karel Th�nissen
1997-03-19  0:00   ` Jon S Anthony
1997-03-19  0:00   ` Ken Garlington
1997-03-20  0:00     ` Richard Kaiser
1997-03-24  0:00       ` Ken Garlington
1997-03-20  0:00     ` Martin Tom Brown
1997-03-21  0:00       ` Frank Manning
1997-03-21  0:00         ` Martin Tom Brown
1997-03-23  0:00           ` Frank Manning
1997-03-25  0:00             ` Ken Garlington
1997-03-19  0:00   ` Ken Garlington
1997-03-20  0:00   ` Robert I. Eachus
1997-03-20  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Karel Th�nissen
1997-03-20  0:00   ` Nick Leaton
1997-03-20  0:00   ` Papers on the Ariane-5 crash and Design by Contract Robert I. Eachus
1997-03-20  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Nick Leaton
     [not found]   ` <tz8sp1qiywm.fsf@aimnet.com>
1997-03-21  0:00     ` Papers on the Ariane-5 crash and Design by Contract ae59
1997-03-21  0:00   ` Ulrich Windl
1997-03-21  0:00   ` Alexander Anderson
1997-03-23  0:00     ` "Paul E. Bennett"
1997-03-21  0:00   ` Please do not start a language war (was " Jon S Anthony
1997-03-22  0:00   ` Bertrand Meyer
1997-03-22  0:00     ` Anders Pytte
1997-03-23  0:00       ` Steve Furlong
1997-03-24  0:00         ` Anders Pytte
1997-03-24  0:00           ` Simulating Eiffel-style assertions (was: Papers on the Ariane-5 crash and Design by Contract) Wolfgang Reddig
1997-03-24  0:00             ` Anders Pytte
1997-03-25  0:00               ` Wolfgang Reddig
1997-03-25  0:00                 ` Anders Pytte
1997-03-31  0:00                 ` Joachim Durchholz
1997-03-26  0:00             ` Alan Brain
1997-03-26  0:00               ` Wolfgang Reddig
1997-03-29  0:00                 ` How old time languages survive EJon
1997-03-22  0:00   ` Bertrand Meyer [this message]
1997-03-23  0:00     ` Papers on the Ariane-5 crash and Design by Contract Dale Stanbrough
     [not found]       ` <3335E18E.33590565@eiffel.com>
1997-03-23  0:00         ` FUD (Re: Papers on the Ariane-5 crash and Design by Contract) Bertrand Meyer
1997-03-24  0:00           ` William Grosso
1997-03-24  0:00             ` William Clodius
1997-03-24  0:00             ` Bertrand Meyer
1997-03-24  0:00             ` Brad Appleton
1997-03-24  0:00     ` Papers on the Ariane-5 crash and Design by Contract Robert Dewar
1997-03-24  0:00       ` Manners (was Re: Papers on the Ariane-5 crash and Design by Contract) Bertrand Meyer
1997-03-25  0:00         ` the one and only real true kibo
1997-03-22  0:00   ` Papers on the Ariane-5 crash and Design by Contract Jon S Anthony
1997-03-28  0:00     ` Matt Kennel (Remove 'nospam' to reply)
1997-03-22  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Stuart Yeates
1997-03-24  0:00   ` Papers on the Ariane-5 crash and Design by Contract Alexander Anderson
1997-03-24  0:00   ` Ken Garlington
1997-03-24  0:00   ` Jon S Anthony
1997-03-24  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Ken Garlington
1997-03-24  0:00   ` Nick Leaton
1997-03-24  0:00   ` Papers on the Ariane-5 crash and Design by Contract Ken Garlington
1997-03-27  0:00     ` Joachim Durchholz
1997-03-31  0:00       ` Ken Garlington
1997-04-06  0:00         ` Joachim Durchholz
1997-03-24  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) William Clodius
1997-03-24  0:00   ` Papers on the Ariane-5 crash and Design by Contract Robb Nebbe
1997-03-24  0:00   ` Ken Garlington
1997-03-24  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) Ken Garlington
1997-03-25  0:00   ` Papers on the Ariane-5 crash and Design by Contract Robert I. Eachus
1997-03-25  0:00   ` Ariane-5: can you clarify? (Re: Please do not start a language war) David Starr
1997-03-25  0:00   ` Ken Garlington
1997-03-25  0:00   ` Ken Garlington
1997-03-26  0:00   ` Papers on the Ariane-5 crash and Design by Contract Ken Garlington
1997-03-26  0:00   ` Alexander Anderson
1997-03-26  0:00   ` Jon S Anthony
1997-03-27  0:00   ` Trust but verify (was " Robert I. Eachus
1997-03-28  0:00   ` Robert I. Eachus
1997-03-28  0:00   ` Jon S Anthony
1997-03-31  0:00   ` Ken Garlington
1997-03-19  0:00 ` Chris Brand
1997-03-23  0:00 ` the one and only real true kibo
  -- strict thread matches above, loose matches on Subject: below --
1997-03-17  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-03-20  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-03-25  0:00 ` Nick Roberts
1997-03-24  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-03-27  0:00 Marin David Condic, 561.796.8997, M/S 731-93
1997-04-03  0:00 Adrian B.Y. Hoe
1997-04-05  0:00 ` Nick Roberts
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox