home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!rational.com!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Subject: Re: Squares and Rectangles (Re: Const Inheritance)
- Message-ID: <rmartin.722272684@thor>
- Sender: news@rational.com
- Organization: Rational
- References: <1992Nov19.171731.23740@ucc.su.OZ.AU> <1992Nov20.012340.19437@fcom.cc.utah.edu>
- Date: Fri, 20 Nov 1992 15:18:04 GMT
- Lines: 49
-
- This has probably already been said, but I would like to reiterate it.
-
- Objects, in the OO paradigm, have both state and behavior. Shapes,
- such as squares and rectangles, in the geomety paradigm, have only
- state. A Square object, in an OO Program, is not equivalent to a
- geometrical square, because it has behaviors as well as state.
-
- A geometrical classification structure would assert that a square is a
- rectangle, because it conforms to all the constraints of a rectangle,
- and adds a few more. In a mathematical world, ISA is the inheritance
- of contraints.
-
- An OO classification structure could not assert that a Square is a
- rectangle, because the Rectangle has behaviors and states that the
- Square cannot inherit. In OO, ISA is the inheritance of state and
- behavior.
-
- Thus, a Square object is not a kind of a Rectangle object. They
- belong in two separate classifications. However, there may be
- conversion functions which convert a Square into a Rectangle. This is
- possible because of the mathematical relationship of the constraints.
-
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- This kind of mismatch between mathematical classification structures
- and OO classification structures is common in OO analysis. It does
- not represent a flaw in either form of representation, it simply
- punctuates that the two forms of modeling are based on different
- premises. Specifically that objects are active entities which must
- have behavior as well as state.
-
- There is an awful lot of chatter about "real-world" modeling in OO.
- It is often asserted (by me as well as others) that OO is "better"
- because we can model our applications in terms of real world objects.
- But there are many different kinds of world views, and OO cannot
- directly represent all of them. This should not be viewed as a
- weakness or a failure. There are no modeling systems which can
- directly represent all world views (Godel). OO is very good at
- representing the kinds of problems which can be solved with a
- computer. Such applications tend to be easy to decompose into objects
- with state and behavior.
-
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-