home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!swrinde!sdd.hp.com!ux1.cso.uiuc.edu!m.cs.uiuc.edu!johnson
- From: johnson@m.cs.uiuc.edu (Ralph Johnson)
- Newsgroups: comp.object
- Subject: Re: Object-Oriented Methodologies - Class Specifications
- Message-ID: <1992Sep1.220559.10346@m.cs.uiuc.edu>
- Date: 1 Sep 92 22:05:59 GMT
- References: <715276480.1.p00058@mail.psi.net>
- Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
- Lines: 47
-
- After examining an example of Rumbaugh's,
- "Ronald C. Schultz" <p00058@mail.psi.net> writes:
-
- >This class specification screams of unnecessary object coupling. Why,
- >for instance, should a circle need to be aware of the existence of
- >lines? or of the existence of windows? To me, this class violates the
- >very concept of a circle as defined in any geometry text.
-
- >My question - can someone please explain to me why they feel this class
- >is legitimate, (or illegitimate for that matter). Why isn't the draw
- >operation and intersectLine operation more appropriately assigned to the
- >drawing application itself, rather than the circle?
-
- I would be happy to. The class looks fine to me. I can see where you
- are coming from, since I have argued with Ed Berard on this point a
- lot. Basically, I think your assumption that a Circle shouldn't know
- anything about a Line is mistaken. You wouldn't want to make Circle
- independent of Point, would you? If you want to be able to intersect
- geometric figures, and I claim that is *essential* to the meaning of
- geometric figures, then you have to be able to compare one with another.
- This means that you have to have something like intersectLine.
-
- I claim that you don't want to make a Circle class that is an independent
- standalone entity. The problem with small classes is that it takes too
- much work to reuse them. There is much bigger payoff when classes come
- in families of similar classes, because then you can learn one class and
- then just reuse your knowledge for all the other classes. A Circle should
- be part of a GeometricObject family of classes. There will be a standard
- set of operations that all the classes must implement, such as intersecting
- with a point or another GeometricObject. These classes will be designed
- as a family and will probably be used as a family. You are unlikely to use
- a Circle in an application and not use a Line.
-
- Draw is definitely more debatable. My guess is that if you ask a Circle
- to draw on a window, it just performs the DrawCircle operation on the
- window, which isn't all that bad. But in general, different applications
- will want to draw on different things, and will want to interpret drawing
- differently. Is color needed? Line-width? Neither of these are attributes
- of Circles, so it seems unreasonable to make Circles be responsible for
- drawing.
-
- In Smalltalk, there is a separation between geometric objects and
- graphical objects. A circle is not displayable. Instead, you have
- to put a wrapper on it that includes color and line width information,
- as well as the display operations.
-
- Ralph Johnson -- University of Illinois at Urbana-Champaign
-