home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11307 comp.object:2958
- Newsgroups: comp.lang.c++,comp.object
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end
- Subject: Re: The "has-a" relation in C++ ? How ?
- Message-ID: <1992Jul21.132202.20742@mole-end>
- Keywords: object,C++,has-a
- Organization: :
- References: <1992Jul20.212525.5081@dsg.tandem.com>
- Date: Tue, 21 Jul 1992 13:22:02 GMT
- Lines: 38
-
- In article <1992Jul20.212525.5081@dsg.tandem.com>, narayan@aravali.everest.tandem.com (Pankaj Narayan) writes:
- > Books typically go over the "is-a" relationship in much detail, saying how
- > C++ has this great inheritance mechanism to support this sort of a
- > relationship.
-
- > However, when it comes to the "has-a" relationship, they don't really talk
- > about or give implementation examples of how that is done in C++. The
- > Coad/Yourdon OOD book talks a little about it, and says that it can be done
- > in a couple of ways, but does not give any substantial example.
-
- > If you know of a book that does have a good example or description of this,
- > please e-mail me your comments.
-
- You do it the same way you do it in C: by members that represent the
- subsidiary objects, or by members that point to the other objects--in
- other words, you are back in the world of data structures. The
- Structured Analysis/Structured Design people have made a very thorough
- study of the topic and any book that covers Data Modelling/Information
- Modelling should tell you all you ever wanted to know.
-
- When I teach OO, I treat Inheritance as something `other than' a
- Relationship; it avoids confusion between the two things that seem to
- be of a different kind. Inheritance is a relationship between two or
- more kinds of category into which a thing falls; other relationships
- are between two or more things (which occasionally may happen to be
- the same). I've gotten great results by identifying Inheritance before
- I even start to _talk_ about Relationships; doing it in other ways led
- to students coming up with many wierd interpretations for Inheritance and
- many wierd class/relationship diagrams reflecting those interpretations.
- When I had them identify the likely Inheritance hierarchies in the problem
- before we even started to talk about relationships, they came up with
- workable class/relationship diagrams for the problem in a few minutes and
- generally on the first try.
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- uunet!mole-end!mat, Somewhere in Matawan, NJ
-