home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+
- From: sm86+@andrew.cmu.edu (Stefan Monnier)
- Newsgroups: comp.object
- Subject: Re: Object-Oriented Methodologies - Class Specifications
- Message-ID: <IeeOI4S00awBQURnxd@andrew.cmu.edu>
- Date: 5 Sep 92 22:28:20 GMT
- Article-I.D.: andrew.IeeOI4S00awBQURnxd
- References: <715276480.1.p00058@mail.psi.net>
- <PFKEB.92Sep5213354@kaon.SLAC.Stanford.EDU>
- Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
- Lines: 68
- In-Reply-To: <PFKEB.92Sep5213354@kaon.SLAC.Stanford.EDU>
-
- Excerpts from netnews.comp.object: 6-Sep-92 Re: Object-Oriented
- Methodo.. Paul Kunz@kaon.SLAC.Stan (1246)
-
- > In article <715276480.1.p00058@mail.psi.net> p00058@mail.psi.net (Ronald
- > C. Schultz) writes:
-
- > This post started a lot of discussion, but nobody seemed to notice
- > what I consider a much more fundamental mistake...
-
-
- > ---- start of quote -------------------------
- > Class Description
- > Class Name: Circle
- > Version: 1.0
- > Description: Ellipse whose major and minor axes are equal
- > Super Classes: Ellipse
- > Features:
- > Public Attributes:
- > center: Point - location of its center
- > radius: Real - its radius
- > Public Methods:
- > draw (Window) - draws a circle in the window
- > intersectLine (Line): Set of Points - finds the
- > intersection of a line and a circle, returns set 0-2 points
- > area(): Real - calculates area of circle
- > perimeter(): Real - calculates circumference of circle
- > Private Methods: none
- > ---- end of quote --------------------------
-
- > Nonsense. A Circle is not a *subclass* of Ellipse, it is a *subset*
- > of all possible Ellipses. There's no need to define such a class.
- > Confusion between subset and subclass is happening here.
- > --
- > Paul F. Kunz pfkeb@slac.stanford.edu (NeXT mail ok)
- > Stanford Linear Accelerator Center, Stanford University
- > Voice: (415) 926-2884 (NeXT) Fax: (415) 926-3587
-
- The problem is not to know if circle is a subclass of ellipse:
-
- It is an ellipse! and inheritance can be interpreted as 'is a'
- (of course, you can interpret it another way, but it is a way).
-
- So you can define circle as a subclass of ellipse. This makes
- sense when you want (for example) to write an intersection
- method which can make use of the particularities of a circle
- (this method could more efficient (cause less general) than the
- one for the ellipse).
- Another example is for the perimeter !
- A perimeter function for an ellipse is not really trivial. But
- it is for a circle !
-
- That's really useful !
-
- In fact, it is the 'raison d'etre' (=~ the real usefulness) of
- the inheritance: add specific behaviour and rewrite some
- methods (using particularities of the child to make it better)
- without having to rewrite all and with the possibility to use
- this new object as if it was of the superclass (I know: it is not
- really clear!)
-
- Stefan Monnier
-
- PS: I hope someone understood most part of it!
- sorry for that poor english !
-
- -----------------------------------------------------
- -- On the average, people seem to be acting normal --
- -----------------------------------------------------
-