home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 19048 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.5 KB  |  38 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsk!pegasus!hansen
  3. From: hansen@pegasus.att.com (Tony L. Hansen)
  4. Subject: Re: Private vs. Protected
  5. Organization: AT&T
  6. Date: Wed, 13 Jan 1993 00:13:37 GMT
  7. Message-ID: <1993Jan13.001337.4609@cbnewsk.cb.att.com>
  8. Summary: law of demeter
  9. Keywords: private, protected, law of demeter
  10. References: <90218@ncratl.AtlantaGA.NCR.COM>
  11. Sender: hansen@cbnewsk.cb.att.com (tony.l.hansen)
  12. Lines: 24
  13.  
  14. < From: vkessler@ncratl.AtlantaGA.NCR.COM (Vance Kessler)
  15. <
  16. < I would like to get your feelings as to when to use private versus when to
  17. < use protected.
  18. <
  19. < I generally make instance variables protected to give direct access to
  20. < sub-classes.  But, I am thinking that it might make maintenance easier to
  21. < make them private and always access them through protected access
  22. < functions.
  23. <
  24. < I would appreciate your opinions on this.
  25.  
  26. You should read up on The Law of Demeter as espoused by Dr. Karl Lieberherr.
  27. It talks about the problems associated with cross-module data dependencies.
  28. In particular, the law itself comes in two forms, called the weak and strong
  29. formulations. The purpose of the law is to build systems that are easier to
  30. understand and maintain. Among other things, the weak version says that
  31. global variables are to be avoided and there should be no public member
  32. data. The strong version goes further and says that there should be no
  33. protected member data either.
  34.  
  35.                     Tony Hansen
  36.                 hansen@pegasus.att.com, tony@attmail.com
  37.                 att!pegasus!hansen, attmail!tony
  38.