home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16640 < prev    next >
Encoding:
Text File  |  1992-11-20  |  2.7 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: Squares and Rectangles (Re: Const Inheritance)
  5. Message-ID: <rmartin.722272684@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <1992Nov19.171731.23740@ucc.su.OZ.AU> <1992Nov20.012340.19437@fcom.cc.utah.edu>
  9. Date: Fri, 20 Nov 1992 15:18:04 GMT
  10. Lines: 49
  11.  
  12. This has probably already been said, but I would like to reiterate it.
  13.  
  14. Objects, in the OO paradigm, have both state and behavior.  Shapes,
  15. such as squares and rectangles, in the geomety paradigm, have only
  16. state.  A Square object, in an OO Program, is not equivalent to a
  17. geometrical square, because it has behaviors as well as state.
  18.  
  19. A geometrical classification structure would assert that a square is a
  20. rectangle, because it conforms to all the constraints of a rectangle,
  21. and adds a few more.  In a mathematical world, ISA is the inheritance
  22. of contraints.
  23.  
  24. An OO classification structure could not assert that a Square is a
  25. rectangle, because the Rectangle has behaviors and states that the
  26. Square cannot inherit.  In OO, ISA is the inheritance of state and
  27. behavior.  
  28.  
  29. Thus, a Square object is not a kind of a Rectangle object.  They
  30. belong in two separate classifications.  However, there may be
  31. conversion functions which convert a Square into a Rectangle.  This is
  32. possible because of the mathematical relationship of the constraints.
  33.  
  34.  
  35. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  36.  
  37. This kind of mismatch between mathematical classification structures
  38. and OO classification structures is common in OO analysis.  It does
  39. not represent a flaw in either form of representation, it simply
  40. punctuates that the two forms of modeling are based on different
  41. premises.  Specifically that objects are active entities which must
  42. have behavior as well as state.
  43.  
  44. There is an awful lot of chatter about "real-world" modeling in OO.
  45. It is often asserted (by me as well as others) that OO is "better"
  46. because we can model our applications in terms of real world objects.
  47. But there are many different kinds of world views, and OO cannot
  48. directly represent all of them.  This should not be viewed as a
  49. weakness or a failure.  There are no modeling systems which can
  50. directly represent all world views (Godel).  OO is very good at
  51. representing the kinds of problems which can be solved with a
  52. computer.  Such applications tend to be easy to decompose into objects
  53. with state and behavior.
  54.  
  55.  
  56. --
  57. Robert Martin                        Training courses offered in:
  58. R. C. M. Consulting                       Object Oriented Analysis
  59. 2080 Cranbrook Rd.                        Object Oriented Design
  60. Green Oaks, Il 60048 (708) 918-1004       C++
  61.