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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Nick Leaton Subject: Re: Visibility and access to "public" attributes Date: 1997/09/05 Message-ID: <341036E9.376A0CA3@calfp.co.uk>#1/1 X-Deja-AN: 270010340 References: <01bcb787$eeb5a180$7e80400a@gavinspc> <34101640.8CF27E0@calfp.co.uk> <01bcba0e$418f7380$2001df0a@gavinspc> Reply-To: nickle@pauillac X-NNTP-Posting-Host: calfp.demon.co.uk [158.152.70.168] Newsgroups: comp.lang.ada,comp.lang.eiffel Date: 1997-09-05T00:00:00+00:00 List-Id: Gavin Collings wrote: > > Nick Leaton wrote in article > <34101640.8CF27E0@calfp.co.uk>... > > > > I did a quick bit of analysis on some Eiffel software. > > > > 193 set_attribute features in 1085 classes, consisting of 84,000 lines > > of code. > > > > This is a very low figure compared to the number of attributes. I think > > the explaination lies with class invariants. > > Yes, 1 in every 5-6 classes is quite low, but not insignificant. I would > imagine from the number of classes in the sample that a good representative > cross section of application was caught. I'm sure the reason you're > pointing to is at least a significant factor. In fact (as we found out on > a circle-ellipse discussion over on comp.object recently) any modifying > operation which can produce an invariant violating state change in an > object gives problems. Direct attribute writes certainly fall into that > category more often than other more benign operations. It is actually much lower than that. If I count the number of classes containing the set attribute features it comes to 48. (They have more than one set attribute feature). The ratio is very low. > > In other languages where you write lots of set attribute features, you > > tend to use them to construct an instance of the class. You cannot do > > this so easily in Eiffel if you have a class invariant, as it must be > > preserved. As a consequence you tend to write a creation routine, which > > takes the necessary arguments, so that you can construct such objects > > without breaking the invariant. > > And a very elegant paradigm it is too. > > > Since your object is now created, there tend to be fewer attributes that > > you want to set once it has been created. > > Especially if the syntax involved isn't especially sweet, and excessive > amounts of typing are involved ;-) Lets save our fingers! ;-) -- Nick Eiffel - Possibly the best language in the world - unless proven otherwise.