comp.lang.ada
 help / color / mirror / Atom feed
From: donh@syd.csa.com.au (Don Harrison)
Subject: Re: Real OO
Date: 1996/03/29
Date: 1996-03-29T00:00:00+00:00	[thread overview]
Message-ID: <Dp08JB.5M8@assip.csasyd.oz> (raw)
In-Reply-To: 4j9s1c$uo5@watnews1.watson.ibm.com

Norman wrote:

:In article <Dov7D0.AtM@assip.csasyd.oz>, donh@syd.csa.com.au (Don Harrison)
:writes: 
:
:|> The Eiffel selective export may seem the wrong way of doing it at first sight.
:|> You might wonder: 
:|>
:|>   "What's the supplier class doing dictating who can and can't use it's
:|>    features? It exists for the purpose of it's clients, so, if anything,
:|>    named subsets of exported features should be provided by a supplier
:|>    and clients should be able to choose which subset they need".
:
:Indeed, I do.

That's okay. I'm a slow learner too :-).
:
:|> However, this would be a violation of Design by Contract because it is the
:|> supplier class that must control it's own state. Therefore, it must dictate
:|> how it's services are used and by whom. If the client were able to able to
:|> choose a particular interface, it might be able to choose one which was more
:|> permissive than the supplier had intended for it and the door would be open
:|> to the client potentially changing the supplier to an inconsistent state.
:
:Selective export cannot control HOW a supplier's services are used, only
:by whom.

The HOW is specified in Eiffel in two ways:

  i)  Selective export not only says WHO but WHAT (attributes/operations).
      The combination of the two reflects the privileges offered by an 
      abstraction to it's partner/client.
  ii) Executable preconditions. (My guess is that these were omitted from 
      Ada 95 because it would be difficult or messy to control the state of 
      individual abstractions because they are co-encapsulated (It's hard
      enough finding them, let alone controlling them!). The other alternative 
      would be to assert at the package level but that would be a complete joke).

Example:

  class A
    feature           -- anyone may use f1
      f1
    feature {B, C}    -- Only instances of partners B and C may use f2
      f2
    feature {A}       -- All instances of A may use f3 (including Current)
      f3
    feature {NONE}    -- Only the current instance of A may use f4 (secret)
      f4.
  end

:Don is suggesting that some modules can be better trusted than
:others to use certain services correctly.

Only because they are designed to co-operate with each other. It would be 
inaccurate to think of this protection only from the perspective of the supplier.
For the client, selective export gives them the reassurance that they can't
inadvertently misuse the supplier's features. There is no such reassurance for
co-encapsulated abstractions. (I wish someone would give me a dollar for every
time I had to fix a bug caused by one component of an Ada package misusing
another!)

:But such modules should not be
:called clients, they should be called partners.

They are partners and also clients. That relationship may be asymmetical in 
cases (eg. the CELL/LIST example) in which CELL exports to LIST and not vice 
versa.  

:  Indeed, Don continues: 
:
:|> The intention of selective export is for classes to make available to 'closely
:|> related' classes features that are intended specifically for them.
:
:Now what do we mean by "closely related"?  In part, we mean that one of
:the classes is implemented in terms of internal features of the other
:(internal at least in the sense that such features are not available to
:the general public).  The classes were probably designed in conjunction
:with each other, most likely by the same group of designers, as part of a
:cooperative system.  By giving its partner access to privileged
:operations, a class is expressing trust in that partner.

Expressing trust, yes, but in specific ways so that the privileges are not
carte blanche.

:....
:|> :  Nesting multiple type
:|> :definitions (suitably hidden) inside a single Ada package accomplishes
:|> :the same thing.
:|>
:|> By no means! The co-encapsulated model destroys the export contract between the
:|> related abstractions. What you end up with is a free-for-all for whoever
:|> happens to live in the same module. "You want to change my state? Well, step
:|> right up and do whatever you like!".
:
:This is a distinction without a difference.

There is an enormous difference.

:  Only parts of the program
:that trust each other live in the same module.  In Eiffel, the definer
:of type A expresses trust in the definer of type B by selectively
:exporting to B the right to use potentially destructive features.  If B
:wants to change A's state, it can "step right up" and do so.  In Ada this
:trust can be expressed by co-encapsulation--declaring A and B in the same
:package.

That trust is misguided because it is unrestricted.

:The issue of scale is important here.

IMO, OO principles are equally relevant at all levels of abstraction. Why? 
Because the essence of OO is (contolled) reuse.

:   The example in question involved
:one type for linked list cells and another type for abstract lists,
:consisting of a length and (a reference to) the first linked cell.
:The whole package is a few dozen lines, conceived as a single entity.
:This is not a toy example.

I don't think anyone said it was.

:  Along with the complex data abstractions
:found in real-world programs are lots and lots of very simple data
:abstractions like this one, and they account for a considerable portion
:of program text.  For multitype data abstractions like this one,
:artificial barriers between the two types just get in the way.

The boundary between the partner abstractions is not a barrier and acknowledging
it's existence only serves to enhance reliability and reusability.

:  Ada
:allows the barriers to be dispensed with at the programmer's discretion;

You sound like a C programmer.

:Eiffel does not.  Ada also allows more intricate program structures,
:involving private child packages, that allow parts of a package's
:implementation to be separately encapsulated and to provide
:features that are hidden from outside clients; however such structures
:are not forced upon the programmer in cases where they are overkill.

Well, gee. And I thought complexity was a bad thing :-).

:....
:|> :Because of the ability to define more than one type in the same module in
:|> :Ada, selective export is of less interest to an Ada programmer than to an
:|> :Eiffel programmer.
:|>
:|> It ought to be, IMO. I suppose, if contracting were treated with the same
:|> importance in Ada as it is in Eiffel, they would be just as interested :-).
:
:Actually, Ada is all about contracts, where they are appropriate.  I am
:reminded of a talk Lou Gerstner gave shortly after he became CEO of IBM,
:in which he expressed his astonishment at the formal legal contracts that
:he found being drawn up between different divisions of the same
:corporation.  This did not diminish in any way his appreciation of the
:importance of contracts with outside parties.

I hope no-one would disagree that formal legal contracts between divisions of
the same corporation are indicative of an apalling corporate culture and that
a co-operative relationship between divisions is a good thing. However, it 
is important to realise that the key to effective operation is a suitable
balance between access to each other's resources and the discipline of how
those resources are made available. A manager of one division cannot just 
march into another and relegate staff from that division without first getting
the approval of that division's manager. Otherwise, the organisation would be 
hopelessly inefficient and collapse due to anarchy. (Perhaps this has some
bearing on IBM's fall from grace :-). However, there are promising signs that 
it is improving).

No, control is still needed, but only as much as required.

:--
:Norman H. Cohen    ncohen@watson.ibm.com

Don.









  reply	other threads:[~1996-03-29  0:00 UTC|newest]

Thread overview: 218+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4id031$cf9@dayuc.dayton.saic.com>
1996-03-18  0:00 ` Real OO Norman H. Cohen
1996-03-18  0:00   ` The Right Reverend Colin James III
1996-03-19  0:00     ` Norman H. Cohen
1996-03-20  0:00       ` Norman Cohen giving IBM a bad name The Right Reverend Colin James III
1996-03-20  0:00         ` Dave Retherford
1996-03-20  0:00         ` Real OO Dale Stanbrough
1996-03-21  0:00           ` Richard Pitre
1996-03-20  0:00         ` Norman Cohen giving IBM a bad name Brian & Karen Bell
1996-03-20  0:00         ` Colin James III giving humans a bad name (was Re: Norman Cohen giving IBM a bad name) David Emery
1996-03-20  0:00           ` Mark R Okern - F95
1996-03-20  0:00             ` Real OO John G. Volan
1996-03-21  0:00               ` Scott Leschke
1996-03-21  0:00                 ` Norman H. Cohen
1996-03-21  0:00                 ` Robert A Duff
1996-03-22  0:00                 ` Don Harrison
1996-03-21  0:00             ` Colin James III giving humans a bad name (was Re: Norman Cohen giving IBM a bad name) Richard A. O'Keefe
1996-03-21  0:00               ` Robert Dewar
1996-03-21  0:00         ` Norman Cohen giving IBM a bad name Kent Mitchell
1996-03-22  0:00         ` Robert Munck
1996-03-22  0:00           ` Mark Brennan
1996-03-22  0:00             ` David Curry
1996-03-23  0:00         ` Tom Reid
1996-03-21  0:00       ` Real OO Don Harrison
1996-03-21  0:00   ` Colin James III giving humans a bad name (was Re: Norman Cohen giving IBM a bad name) Ulrich Windl
1996-03-20  0:00 ` Real OO Don Harrison
1996-03-22  0:00 ` Don Harrison
1996-03-22  0:00   ` Norman H. Cohen
1996-03-27  0:00     ` Don Harrison
1996-03-27  0:00       ` Norman H. Cohen
1996-03-28  0:00         ` Jacob Gore
1996-04-04  0:00         ` Don Harrison
1996-04-04  0:00           ` Jon S Anthony
1996-04-04  0:00           ` Tucker Taft
1996-04-04  0:00             ` Tucker Taft
1996-04-12  0:00               ` Don Harrison
1996-04-12  0:00             ` Don Harrison
1996-04-15  0:00               ` Robert I. Eachus
1996-04-19  0:00                 ` Don Harrison
1996-04-19  0:00                   ` Matt Kennel
1996-04-20  0:00                     ` Bob Hathaway
1996-04-23  0:00                     ` Don Harrison
1996-04-04  0:00           ` Robb Nebbe
1996-04-04  0:00           ` Laurent Guerby
1996-03-22  0:00   ` Norman H. Cohen
1996-03-26  0:00     ` Don Harrison
1996-03-26  0:00       ` Norman H. Cohen
1996-03-29  0:00         ` Don Harrison [this message]
1996-03-27  0:00       ` Thomas Beale
1996-03-28  0:00         ` Don Harrison
1996-03-23  0:00   ` Joachim Durchholz
1996-03-26  0:00     ` Norman H. Cohen
1996-04-04  0:00       ` Don Harrison
1996-04-04  0:00         ` Jon S Anthony
1996-04-12  0:00           ` Don Harrison
1996-04-17  0:00             ` Jon S Anthony
1996-04-19  0:00               ` Don Harrison
1996-04-19  0:00                 ` Multiple Dispatch in Ada 95 (Was Re: Real OO) Robert I. Eachus
1996-04-19  0:00                 ` Real OO Jon S Anthony
1996-04-23  0:00                   ` Don Harrison
1996-04-24  0:00                     ` Don Harrison
1996-04-29  0:00                     ` Jon S Anthony
1996-04-30  0:00                       ` Robert Dewar
1996-04-30  0:00                         ` Robert A Duff
1996-04-30  0:00                           ` Robert Dewar
1996-05-01  0:00                             ` Richard Bielak
1996-04-30  0:00                           ` Amit Patel
1996-05-01  0:00                           ` Adam Beneschan
1996-05-02  0:00                             ` Ell
1996-04-30  0:00                         ` Amit Patel
1996-04-30  0:00                           ` Robert A Duff
1996-05-07  0:00                             ` Amit Patel
1996-05-01  0:00                           ` Norman H. Cohen
1996-05-01  0:00                             ` Colin James III (The Rt Rev'd)
1996-05-07  0:00                             ` Amit Patel
1996-05-01  0:00                         ` AdaWorks
1996-05-01  0:00                         ` Don Harrison
1996-05-01  0:00                           ` David Hopwood
1996-05-03  0:00                             ` Don Harrison
1996-05-01  0:00                           ` Don Harrison
1996-05-02  0:00                             ` Robert A Duff
1996-05-03  0:00                               ` Don Harrison
1996-05-03  0:00                                 ` Robert A Duff
1996-05-06  0:00                                   ` Don Harrison
1996-05-06  0:00                                     ` Robb Nebbe
1996-05-06  0:00                                     ` Robert A Duff
1996-05-02  0:00                           ` Robert A Duff
1996-05-03  0:00                             ` Don Harrison
1996-05-10  0:00                             ` Don Harrison
1996-05-08  0:00                         ` Joachim Durchholz
1996-05-03  0:00                       ` Don Harrison
1996-05-03  0:00                         ` Dave Fitch
1996-05-07  0:00                         ` Jon S Anthony
1996-04-30  0:00                     ` Joachim Durchholz
1996-04-30  0:00                     ` Jon S Anthony
1996-05-01  0:00                       ` Matt Kennel
1996-05-03  0:00                         ` Don Harrison
1996-05-02  0:00                       ` Don Harrison
1996-05-02  0:00                         ` Robert I. Eachus
1996-05-02  0:00                         ` Jon S Anthony
1996-05-03  0:00                           ` Don Harrison
1996-05-06  0:00                             ` Jon S Anthony
1996-05-06  0:00                         ` Jon S Anthony
1996-05-06  0:00                       ` Don Harrison
1996-05-06  0:00                         ` Don Harrison
1996-05-07  0:00                         ` Jon S Anthony
1996-05-13  0:00                           ` Don Harrison
1996-05-09  0:00                         ` Jon S Anthony
1996-04-19  0:00                 ` Multiple Dispatch in Ada 95 (Was Re: Real OO) Brian Rogoff
1996-04-21  0:00                   ` Brian Rogoff
1996-04-20  0:00                 ` Brian Rogoff
1996-04-21  0:00                   ` Robert A Duff
1996-04-24  0:00                 ` Real OO Joachim Durchholz
1996-05-01  0:00                   ` Matt Kennel
1996-05-02  0:00                     ` Don Harrison
1996-05-07  0:00                   ` Joachim Durchholz
1996-05-08  0:00                   ` Jon S Anthony
1996-05-09  0:00                   ` Robert I. Eachus
1996-04-30  0:00                 ` Jon S Anthony
1996-05-03  0:00                   ` Don Harrison
1996-05-07  0:00                     ` Jon S Anthony
1996-04-30  0:00                 ` Joachim Durchholz
1996-05-08  0:00                   ` Joachim Durchholz
1996-05-10  0:00                   ` Jon S Anthony
1996-05-02  0:00                 ` Jon S Anthony
1996-05-06  0:00                 ` Jon S Anthony
1996-04-08  0:00         ` Norman H. Cohen
1996-04-08  0:00           ` Robert A Duff
1996-04-09  0:00             ` Norman H. Cohen
1996-04-10  0:00           ` Don Harrison
1996-04-11  0:00           ` Jacob Gore
1996-04-12  0:00           ` Don Harrison
1996-04-12  0:00             ` Jacob Gore
1996-04-16  0:00               ` Don Harrison
1996-04-12  0:00           ` Don Harrison
1996-04-12  0:00             ` Jon S Anthony
1996-04-13  0:00               ` Robert A Duff
1996-04-12  0:00             ` Matt Kennel
1996-04-15  0:00               ` Don Harrison
1996-04-16  0:00             ` Jon S Anthony
1996-04-09  0:00         ` Jon S Anthony
1996-04-09  0:00         ` Valery CROIZIER
1996-04-09  0:00       ` Joachim Durchholz
1996-05-02  0:00       ` Joachim Durchholz
1996-05-05  0:00         ` Robert A Duff
1996-05-05  0:00           ` Robert Dewar
1996-05-06  0:00         ` Norman H. Cohen
1996-05-07  0:00           ` Don Harrison
1996-05-07  0:00             ` Jon S Anthony
1996-05-08  0:00               ` Don Harrison
1996-05-08  0:00             ` Norman H. Cohen
1996-05-08  0:00               ` Robert A Duff
1996-05-10  0:00                 ` Matt Kennel
1996-05-10  0:00                   ` Robert A Duff
1996-05-14  0:00                     ` Matt Kennel
1996-05-15  0:00                       ` Robert A Duff
1996-05-07  0:00           ` Ada terminology (was Re: Real OO) David Hopwood
1996-05-07  0:00             ` Dave Jones
1996-05-07  0:00             ` Tucker Taft
1996-05-07  0:00               ` The Right Reverend Colin James III
1996-05-08  0:00               ` bill.williams
1996-05-07  0:00             ` The Right Reverend Colin James III
1996-05-07  0:00         ` Real OO Amit Patel
1996-05-07  0:00           ` The Right Reverend Colin James III
1996-05-08  0:00           ` Don Harrison
1996-05-08  0:00             ` Juergen Schlegelmilch
     [not found]               ` <Dr4538.D27@assip.csasyd.oz>
1996-05-09  0:00                 ` Richard Riehle
1996-05-10  0:00                   ` Tucker Taft
1996-05-13  0:00                     ` Don Harrison
1996-05-13  0:00                       ` Tucker Taft
1996-05-14  0:00                         ` Roger Browne
1996-05-14  0:00                         ` Joachim Durchholz
1996-05-14  0:00                         ` Don Harrison
1996-05-14  0:00                           ` Robert A Duff
1996-05-14  0:00                           ` Steve Tynor
1996-05-14  0:00                             ` Robert A Duff
1996-05-15  0:00                             ` Don Harrison
1996-05-15  0:00                           ` Steve Tynor
1996-05-15  0:00                             ` Robert A Duff
1996-05-16  0:00                           ` James McKim
1996-05-18  0:00                             ` Matt Kennel
1996-05-20  0:00                               ` James McKim
1996-05-22  0:00                                 ` Matt Kennel
1996-05-15  0:00                         ` Steve Tynor
1996-05-15  0:00                         ` Alexander Kjeldaas
1996-05-19  0:00                         ` Piercarlo Grandi
1996-05-14  0:00                   ` James McKim
1996-05-15  0:00                     ` Juergen Schlegelmilch
1996-05-09  0:00                 ` Juergen Schlegelmilch
1996-05-20  0:00               ` Joachim Durchholz
1996-05-07  0:00       ` Joachim Durchholz
1996-05-09  0:00         ` Don Harrison
1996-05-09  0:00           ` Joachim Durchholz
1996-05-09  0:00           ` Jon S Anthony
1996-04-02  0:00     ` Detecting type mismatch at compile time (was Re: Real OO) Robert I. Eachus
1996-04-03  0:00       ` Richard Bielak
1996-04-04  0:00       ` Don Harrison
1996-03-28  0:00   ` Real OO Joachim Durchholz
1996-03-29  0:00     ` Norman H. Cohen
1996-03-30  0:00       ` John G. Volan
1996-03-26  0:00 ` Jon S Anthony
1996-03-29  0:00 ` Joachim Durchholz
1996-04-04  0:00   ` Don Harrison
1996-04-04  0:00     ` Steve Tynor
1996-04-08  0:00       ` Norman H. Cohen
1996-04-09  0:00         ` Matt Kennel
1996-04-04  0:00     ` Dominique Colnet
1996-04-08  0:00     ` Matt Kennel
1996-04-09  0:00       ` Norman H. Cohen
1996-04-09  0:00     ` Robert C. Martin
1996-04-10  0:00     ` J. Kanze
1996-05-02  0:00 Bob Crispen
     [not found] <DoDLr7.JDB@world.std.com>
     [not found] ` <4if7s5$bfk@ra.nrl.navy.mil>
     [not found]   ` <DoDqH4.29v@world.std.com>
1996-03-26  0:00     ` AdaWorks
1996-03-29  0:00   ` Brian Rogoff
     [not found] <4hneps$1238@watnews1.watson.ibm.com>
     [not found] ` <Do3F1K.4xG@assip.csasyd.oz>
     [not found]   ` <4i455s$ijq@watnews1.watson.ibm.com>
1996-03-15  0:00     ` Don Harrison
     [not found]       ` <DoBH80.9u9@world.std.com>
1996-03-15  0:00         ` Richard Pitre
1996-03-15  0:00         ` Mark A Biggar
1996-03-16  0:00     ` Des  Kenny
     [not found] <JSA.96Mar13143956@organon.com>
1996-03-15  0:00 ` Don Harrison
replies disabled

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