Article View: comp.lang.objective-c
Article #289Re: Proper way to access superclass instance variables
From: Carsten Schultz
Date: Sun, 22 Nov 1992 11:58
Date: Sun, 22 Nov 1992 11:58
39 lines
1997 bytes
1997 bytes
In article <1992Nov18.213742.493@afs.com> Michael_Pizolato@afs.com (Michael Pizolato) writes: > A question of philosophy. Consider the following classes: > [...] > I can't think of any good reason to access 'value' directly unless I have complete control over the implementation of the Foo class. Even if I do, it's painful to change every subclass of Foo that might use 'value' directly if I change Foo as above. > Any thoughts? Of course, there's a reason to use the variables directly: it's faster. But of course it's dangerous to do so, for the reasons you mentioned. In case of classes you didn't implement yourself, you should only directly acces variables, if it seems necessary and they're documented. Maybe someone who doesn't want the variables to be used should declare them private. > > Thanx, > Michael > > P.S. Given the conclusion that ivars should only ever be accessed through methods, it seems wrong that they appear in the @interface section. Of course we can't change it now, but does anyone know why they're there? I always thought, that this is, because the compiler sometimes needs to know the size of the object; but now that I think about it, I can't think of an example (at least not with nice Objective-C code). > > -- > Michael_Pizolato@afs.com > ~18 kyu > Q16 > NeXTMail appreciated Carsten
Technical Details
Message-ID:
<1ensl0INNecg@mailgzrz.TU-Berlin.DE>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!mailgzrz.TU-Berlin.DE!newsReferences:
<1992Nov18.213742.493@afs.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!mailgzrz.TU-Berlin.DE!news From: carsten@pizza.fb10.tu-berlin.de (Carsten Schultz) Newsgroups: comp.lang.objective-c Subject: Re: Proper way to access superclass instance variables Date: 22 Nov 1992 11:58:24 GMT Organization: ZRZ/TU-Berlin Lines: 39 Distribution: world Message-ID: <1ensl0INNecg@mailgzrz.TU-Berlin.DE> References: <1992Nov18.213742.493@afs.com> Reply-To: carsten@pizza.fb10.tu-berlin.de (Carsten Schultz) NNTP-Posting-Host: pizza.fb10.tu-berlin.de