From: nospam@thanks.com.au (Don Harrison)
Subject: Re: Visibility and access to "public" attributes
Date: 1997/09/02
Date: 1997-09-02T00:00:00+00:00 [thread overview]
Message-ID: <EFuyKK.J61@syd.csa.com.au> (raw)
In-Reply-To: 872873007.3110@dejanews.com
Mike Card wrote:
[..]
Example of how to emulate Eiffel's look-but-dont-touch attributes:
:package Test1 is
: type My_Type is tagged private; -- attributes invisible
: function A(Obj : My_Type) return Boolean; -- access function
:private
: type My_Type is tagged
: record
: A : Boolean; -- attribute
: end record;
:end Test1;
:
:
:package body Test1 is
: function A(Obj : My_Type) return Boolean
: is
: begin
: return Obj.A;
: end A;
:end Test1;
I accept this more accurately emulates the Eiffel functionality, and..
:.. there is no restriction in Ada that prevents an access function
:from having the same name as a class' (tagged type's) attribute.
True.
:That said, I think it is fair to say that I believe the idea behind
:Ada's "all or nothing" approach is that you may want to ensure that
:a client never depends on some of a type's attributes.
As you acknowledge below, this can be done in Eiffel by hiding all the
attributes of the type.. (See slso my response to Jon).
:I know that Eiffel can totally hide the attributes of an object (i.e.
:accessed via methods only) as well. When writing Eiffel programs, how
:do you decide when to make a type's attributes "read-only visible"
:and when to hide them?
You export them when they're needed (or may be needed) by clients; otherwise,
you hide them.
Mike subsequently wrote:
:Now, suppose you change the AIRCRAFT class to have jet engines and
:thus remove or change the Propeller_RPM attribute? Because it was
:*visible*, someone may have written code to read it and now if you
:change the spec of the class their code will break. It doesn't
:matter that they can't update the attribute! If they can refer to it
:at all and you remove the attribute from the class definition, their
:code is broken!
As others have pointed out, the problem here is that your design for the
AIRCRAFT class, rather than the Eiffel mechanism, is deficient - it
assumed the aircraft was propeller-driven.
Don. (Reverse to reply)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Don Harrison au.com.csa.syd@donh
next prev parent reply other threads:[~1997-09-02 0:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-08-29 0:00 Visibility and access to "public" attributes card
1997-08-29 0:00 ` Patrick Doyle
[not found] ` <JSA.97Aug29190453@alexandria.organon.com>
1997-08-30 0:00 ` Patrick Doyle
1997-08-30 0:00 ` Jon S Anthony
1997-09-01 0:00 ` Patrick Doyle
1997-08-30 0:00 ` Darren New
1997-09-02 0:00 ` Don Harrison [this message]
1997-09-02 0:00 ` Don Harrison
1997-09-02 0:00 ` Gavin Collings
1997-09-02 0:00 ` Nick Leaton
1997-09-02 0:00 ` Gavin Collings
1997-09-02 0:00 ` Patrick Doyle
1997-09-03 0:00 ` Don Harrison
1997-09-05 0:00 ` Nick Leaton
[not found] ` <01bcba0e$418f7380$2001df0a@gavinspc>
1997-09-05 0:00 ` Nick Leaton
1997-09-05 0:00 ` Patrick Doyle
1997-09-02 0:00 ` Jon S Anthony
1997-09-02 0:00 ` Peter Horan
-- strict thread matches above, loose matches on Subject: below --
1997-09-02 0:00 card
1997-08-29 0:00 card
1997-08-29 0:00 ` Ted Velkoff
1997-08-30 0:00 ` Darren New
1997-08-30 0:00 ` Patrick Doyle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox