Path: utzoo!utgpu!water!watmath!clyde!att-cb!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!hplabs!hp-pcd!hplsla!jima From: jima@hplsla.HP.COM ( Jim Adcock) Newsgroups: comp.lang.c++ Subject: Re: Critique of Wiener/Pinson Message-ID: <6590037@hplsla.HP.COM> Date: 15 Apr 88 21:03:40 GMT References: <8063@apple.Apple.Com> Organization: HP Lake Stevens, WA Lines: 34 I don't buy the idea that instance variables of an object must always be accessed via an access method. I think there are good cases for violating this "rule". The simplest case that comes to mind is the overused example of complex numbers. To suggest that: x = myComplexNumber.re(); y = myComplexNumber.im(); is in any way better than: x = myComplexNumber.re; y = myComplexNumber.im; seems ludicrous to me. In fact, I believe that in many situations similar to the complex number example, allowing direct access is preferrable to forcing the class's user to always tag on the "meaningless" () parenthesis. In any case, I believe the important operative rule that's in effect here is that the class definer define the public portion of the interface to his/her class in a way that is not going to change in future revisions of the class. If you, the designer, are willing to "guarantee" that those portions of your object that you allow access to directly are not going to change in future revisons of your class, then I say, "no problem, give the class user direct access." If you don't feel you can make such a guarantee, then please make sure to supply access functions instead of allowing direct access to those instance variables that may be changed in future revisions. [If in doubt, use access functions]