From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,8ff80a74f45b5cd3 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,8ff80a74f45b5cd3 X-Google-Attributes: gid103376,public From: doylep@ecf.toronto.edu (Patrick Doyle) Subject: Re: Visibility and access to "public" attributes Date: 1997/08/30 Message-ID: #1/1 X-Deja-AN: 269073255 Sender: news@ecf.toronto.edu (News Administrator) References: <872873007.3110@dejanews.com> X-Nntp-Posting-Host: skule.ecf Organization: University of Toronto, Engineering Computing Facility Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-08-30T00:00:00+00:00 List-Id: In article , Jon S Anthony wrote: >In article doylep@ecf.toronto.edu (Patrick Doyle) writes: > >> class TEST1 >> >> feature >> >> A : BOOLEAN >> >> end >> >> Of course, every language has things it's good at and things >> it's not so good at, but this to me seems a fairly common pattern >> in OOP. > >I don't see how this is "better" overall. It has its own >disadvantages. In the Ada case you can completely change the >representation including the name of the attribute while keeping the >accessors the same and not disturbing client code. In the Eiffel case >you can "hedge your bets" by not committing to this sort of thing up >front (and thus possibly shooting yourself in the foot later). It's >just not that big of a deal as neither has any clear _objective_ >superiority over the other. Watch this: class TEST1 feature {ANY} A : BOOLEAN is do Result := (B = 0) end feature {NONE} B : INTEGER end I've changed the name and type of the attribute, and the public interface has remained the same. If this isn't what you were talking about, could you explain? >> If the attributes change, then what used to be an attribute >> can be changed into a function with absolutely no effect on >> client code. > >Not if the name changes as well. See above. >> What I'd like to know is, how do you decide in Ada whether >> to make an attribute public, and thus irrevocably commit to >> allowing clients to assign to it? > >How is this an Ada or Eiffel or any language issue? That's basically >a design issue. IMO, you should _always_ make the things private >except for quick hacks. I guess it's just a language issue because Eiffel doesn't allow data members to be assigned-to by clients. Thus, if you're using Eiffel, you never have to make this decision. There are drawbacks-- you can't do the "quick hacks" you were talking about. -PD -- -- Patrick Doyle doylep@ecf.utoronto.ca