home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / objectiv / 677 < prev    next >
Encoding:
Internet Message Format  |  1992-11-21  |  1.9 KB

  1. Path: 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
  2. From: carsten@pizza.fb10.tu-berlin.de (Carsten Schultz)
  3. Newsgroups: comp.lang.objective-c
  4. Subject: Re: Proper way to access superclass instance variables
  5. Date: 22 Nov 1992 11:58:24 GMT
  6. Organization: ZRZ/TU-Berlin
  7. Lines: 39
  8. Distribution: world
  9. Message-ID: <1ensl0INNecg@mailgzrz.TU-Berlin.DE>
  10. References: <1992Nov18.213742.493@afs.com>
  11. Reply-To: carsten@pizza.fb10.tu-berlin.de (Carsten Schultz)
  12. NNTP-Posting-Host: pizza.fb10.tu-berlin.de
  13.  
  14. In article <1992Nov18.213742.493@afs.com> Michael_Pizolato@afs.com  
  15. (Michael Pizolato) writes:
  16. > A question of philosophy.  Consider the following classes:
  17. [...]
  18. > I can't think of any good reason to access 'value' directly unless I  
  19. have complete control over the implementation of the Foo class.  Even if I  
  20. do, it's painful to change every subclass of Foo that might use 'value'  
  21. directly if I change Foo as above. 
  22. > Any thoughts?
  23.  
  24. Of course, there's a reason to use the variables directly: it's faster.  
  25. But of course it's dangerous to do so, for the reasons you mentioned. In  
  26. case of classes you didn't implement yourself, you should only directly  
  27. acces variables, if it seems necessary and they're documented. Maybe  
  28. someone who doesn't want the variables to be used should declare them  
  29. private.
  30.  
  31. > Thanx,
  32. > Michael
  33. > P.S.  Given the conclusion that ivars should only ever be accessed  
  34. through methods, it seems wrong that they appear in the @interface  
  35. section.  Of course we can't change it now, but does anyone know why  
  36. they're there?
  37.  
  38. I always thought, that this is, because the compiler sometimes needs to  
  39. know the size of the object; but now that I think about it, I can't think  
  40. of an example (at least not with nice Objective-C code).
  41.  
  42. > --
  43. > Michael_Pizolato@afs.com
  44. > ~18 kyu
  45. > Q16
  46. > NeXTMail appreciated
  47.  
  48. Carsten
  49.