home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / object / 3442 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  3.1 KB

  1. Path: sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+
  2. From: sm86+@andrew.cmu.edu (Stefan Monnier)
  3. Newsgroups: comp.object
  4. Subject: Re: Object-Oriented Methodologies - Class Specifications
  5. Message-ID: <IeeOI4S00awBQURnxd@andrew.cmu.edu>
  6. Date: 5 Sep 92 22:28:20 GMT
  7. Article-I.D.: andrew.IeeOI4S00awBQURnxd
  8. References: <715276480.1.p00058@mail.psi.net>
  9.     <PFKEB.92Sep5213354@kaon.SLAC.Stanford.EDU>
  10. Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  11. Lines: 68
  12. In-Reply-To: <PFKEB.92Sep5213354@kaon.SLAC.Stanford.EDU>
  13.  
  14. Excerpts from netnews.comp.object: 6-Sep-92 Re: Object-Oriented
  15. Methodo.. Paul Kunz@kaon.SLAC.Stan (1246)
  16.  
  17. > In article <715276480.1.p00058@mail.psi.net> p00058@mail.psi.net (Ronald
  18. > C. Schultz) writes:
  19.  
  20. > This post started a lot of discussion, but nobody seemed to notice
  21. > what I consider a much more fundamental mistake...
  22.  
  23.  
  24. >    ---- start of quote -------------------------
  25. >    Class Description
  26. >    Class Name: Circle
  27. >    Version: 1.0
  28. >    Description: Ellipse whose major and minor axes are equal
  29. >    Super Classes: Ellipse
  30. >    Features:
  31. >        Public Attributes:
  32. >            center: Point - location of its center
  33. >            radius: Real - its radius
  34. >        Public Methods: 
  35. >            draw (Window) - draws a circle in the window
  36. >            intersectLine (Line): Set of Points - finds the 
  37. >    intersection of a line and a circle, returns set 0-2 points
  38. >            area(): Real - calculates area of circle
  39. >            perimeter(): Real - calculates circumference of circle
  40. >        Private Methods: none
  41. >    ---- end of quote --------------------------
  42.  
  43. > Nonsense.   A Circle is not a *subclass* of Ellipse, it is a *subset*
  44. > of all possible Ellipses.   There's no need to define such a class.
  45. > Confusion between subset and subclass is happening here.
  46. > --
  47. > Paul F. Kunz    pfkeb@slac.stanford.edu (NeXT mail ok)
  48. > Stanford Linear Accelerator Center, Stanford University
  49. > Voice: (415) 926-2884   (NeXT) Fax: (415) 926-3587
  50.  
  51. The problem is not to know if circle is a subclass of ellipse:
  52.  
  53. It is an ellipse! and inheritance can be interpreted as 'is a'
  54. (of course, you can interpret it another way, but it is a way).
  55.  
  56. So you can define circle as a subclass of ellipse. This makes
  57. sense when you want (for example) to write an intersection
  58. method which can make use of the particularities of a circle 
  59. (this method could more efficient (cause less general) than the
  60. one for the ellipse).
  61. Another example is for the perimeter !
  62. A perimeter function for an ellipse is not really trivial. But
  63. it is for a circle !
  64.  
  65. That's really useful !
  66.  
  67. In fact, it is the 'raison d'etre' (=~ the real usefulness) of
  68. the inheritance: add specific behaviour and rewrite some 
  69. methods (using particularities of the child to make it better)
  70. without having to rewrite all and with the possibility to use
  71. this new object as if it was of the superclass (I know: it is not
  72. really clear!)
  73.  
  74.     Stefan Monnier
  75.  
  76. PS: I hope someone understood most part of it!
  77.     sorry for that poor english ! 
  78.  
  79. -----------------------------------------------------
  80. -- On the average, people seem to be acting normal --
  81. -----------------------------------------------------
  82.