home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!rational.com!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Subject: Re: Multiple Header Files Problem
- Message-ID: <rmartin.722283008@thor>
- Sender: news@rational.com
- Organization: Rational
- References: <1992Nov10.164547.19059@mprgate.mpr.ca> <5189@holden.lulea.trab.se> <1240@saxony.pa.reuter.COM>
- Date: Fri, 20 Nov 1992 18:10:08 GMT
- Lines: 44
-
- dgil@pa.reuter.COM (Dave Gillett) writes:
-
- | It's pretty hard to get into this fix except by making heavy use of
- |inline methods. Dare I suggest that anyone who regards this as a "very
- |serious" problem is *probably* inlining too much?
-
- excessive inline-ing is one of the most common flaws made by novice
- users of C++. The tempatation to inline is strong, and the
- disadvantages are not obvious. This attitude can lead a development
- team into a very nasty situation involving long convoluted dependency
- cycles. It is not always easy to figure out how to break them.
-
- As a basic rule of thumb, functions which access the members of other
- classes should not be inlined. If this rule is followed consistently,
- then inlining will never cause a dependency cycle.
-
- The other source of dependency cycles that you mentioned was
- "containment by value". i.e.
-
- class A
- {
- public:
- B itsB;
- };
-
- class B
- {
- public:
- A itsA;
- };
-
- This can be broken by containing one or both members by reference.
- (i.e. use pointers or references instead of values). Such a practice
- also brings the benefit that the contained object can be polymorphic.
- Objects contained by value cannot be polymorpic, but objects contained
- by reference can.
-
- Thus, another rule of thumb is: "where possible, contain by
- reference."
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-