home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object
- Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!m.cs.uiuc.edu!johnson
- From: johnson@m.cs.uiuc.edu (Ralph Johnson)
- Subject: Re: Object-Oriented Methodologies - Class Specifications
- Message-ID: <1992Sep3.033015.31493@m.cs.uiuc.edu>
- Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
- References: <1992Sep1.220559.10346@m.cs.uiuc.edu> <715276480.1.p00058@mail.psi.net> <1992Sep2.135247.11696@bcrka451.bnr.ca>
- Date: Thu, 3 Sep 1992 03:30:15 GMT
- Lines: 44
-
- In response to an article of mine, sjm@bcrki65.bnr.ca (Stuart MacMartin) writes:
-
- >Yes, I suppose. But intersectLine??? Do you really support having a
- >pair-wise solution? If I want to add another GeometricObject if there are,
- >say, 10 already, do I add 10 intersection methods???? What about the
- >symmetric intersection methods in the other classes? How do I then find
- >the intersection of two arbitrary geometric objects? Must I be able to
- >find the types at runtime?
-
- Let's forget about OOP, and just think about geometry. An algorithm to
- test whether two circles intersect is different from one that tests whether
- a cicle intersects with a line, or whether two rectangles intersect.
- We can have default approximate algorithms, like check whether the bounding
- boxes of the two geometric objects intersect. We can also have slower
- algorithms for arbitrary polygons that can be replaced by more efficient
- algorithms for special cases like rectangles. The *problem domain* implies
- that a solution will have to have lots of special cases.
-
- Several people have mentioned that CLOS generic functions are the correct
- solution to this problem, and they are right. Those of us who use
- languages without generic functions use double-dispatching to solve the
- problem, which is essentially the same as generic functions if you squint
- right. (Since I program in Smalltalk and C++, I have a perpetual squint.)
- This has the obvious problems that adding new classes requires modifying
- existing ones, but that is because we are dealing with a problem whose
- solution depends on the classes of more than one object. If you don't
- like that then you can always go back to CASE statements. The real solution
- is to provide better language and programming environment support for
- operations that depend on the class of several objects, whether this
- be generic functions or something else.
-
- >I don't want my compiling or (especially!) my module size to be
- >adversely affected. I have seen cases where using one routine from a
- >utility package increased the size of the executable by 50% because of all
- >the extraneous junk that was pulled in due to this packaging philosophy.
- >Will this happen in your case, or am I unduly worried about a problem that
- >doesn't appear in standard OO languages?
-
- This will happen in all the C++ systems I know about. Smalltalk systems
- leave the decision for what gets included up to you (by letting you specify
- what gets stripped), which is no better. Language implementers need to
- take this problem seriously, or it will inhibit the use of reusable software.
-
- Ralph Johnson -- University of Illinois at Urbana-Champaign
-