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: dnew@zloty.fv.com (Darren New) Subject: Re: Visibility and access to "public" attributes Date: 1997/08/30 Message-ID: <5u7oov$305@newshub.atmnet.net>#1/1 X-Deja-AN: 269008979 References: <872873007.3110@dejanews.com> Organization: FIRST VIRTUAL Holdings Inc. Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-08-30T00:00:00+00:00 List-Id: In article <872873007.3110@dejanews.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