comp.lang.ada
 help / color / mirror / Atom feed
From: dnew@zloty.fv.com (Darren New)
Subject: Re: Visibility and access to "public" attributes
Date: 1997/08/30
Date: 1997-08-30T00:00:00+00:00	[thread overview]
Message-ID: <5u7oov$305@newshub.atmnet.net> (raw)
In-Reply-To: 872873007.3110@dejanews.com


In article <872873007.3110@dejanews.com>,  <card@syr.lmco.com> wrote:

>In Eiffel, by contrast, a type can be "semi-private", by which I mean
>that its attributes can be made visible for read purposes but not
>write purposes. 

I think you're thinking about this wrong. Think of an Eiffel "attribute"
as a function.  There happens to be special syntax you can use to determine
what that function returns, and you can only use that syntax inside the
body of the class declaring the attribute.

Given this, you're not exposing any internal details, any more than 
writing an Ada access function exposes internal details.

>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. 

Then put the attribute you don't want seen in a "feature {NONE}" clause.
This is like complaining that you're writing access functions for
private variables you don't want clients seeing.

> For instance,
>you might have an Aircraft class with a Take_Off method. Should a
>client be able to view (and thus potentially depend upon) attributes
>in the Aircraft type that might change but would not impact the
>interface to Take_Off?

No. So hide them. :-)

>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?

When you're willing for a client to depend on the value of the
attribute, then you make it visible. This is no different at all
from making visible access functions.

-- Darren




  parent reply	other threads:[~1997-08-30  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 [this message]
1997-09-02  0:00 ` Don Harrison
1997-09-02  0:00   ` Peter Horan
1997-09-02  0:00   ` Don Harrison
1997-09-02  0:00     ` Jon S Anthony
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
1997-09-05  0:00         ` Patrick Doyle
     [not found]         ` <01bcba0e$418f7380$2001df0a@gavinspc>
1997-09-05  0:00           ` Nick Leaton
  -- 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