home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsk!pegasus!hansen
- From: hansen@pegasus.att.com (Tony L. Hansen)
- Subject: Re: Private vs. Protected
- Organization: AT&T
- Date: Wed, 13 Jan 1993 00:13:37 GMT
- Message-ID: <1993Jan13.001337.4609@cbnewsk.cb.att.com>
- Summary: law of demeter
- Keywords: private, protected, law of demeter
- References: <90218@ncratl.AtlantaGA.NCR.COM>
- Sender: hansen@cbnewsk.cb.att.com (tony.l.hansen)
- Lines: 24
-
- < From: vkessler@ncratl.AtlantaGA.NCR.COM (Vance Kessler)
- <
- < I would like to get your feelings as to when to use private versus when to
- < use protected.
- <
- < I generally make instance variables protected to give direct access to
- < sub-classes. But, I am thinking that it might make maintenance easier to
- < make them private and always access them through protected access
- < functions.
- <
- < I would appreciate your opinions on this.
-
- You should read up on The Law of Demeter as espoused by Dr. Karl Lieberherr.
- It talks about the problems associated with cross-module data dependencies.
- In particular, the law itself comes in two forms, called the weak and strong
- formulations. The purpose of the law is to build systems that are easier to
- understand and maintain. Among other things, the weak version says that
- global variables are to be avoided and there should be no public member
- data. The strong version goes further and says that there should be no
- protected member data either.
-
- Tony Hansen
- hansen@pegasus.att.com, tony@attmail.com
- att!pegasus!hansen, attmail!tony
-