Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!rex!spool.mu.edu!agate!apple!netcomsv!jls From: jls@netcom.COM (Jim Showalter) Newsgroups: comp.object Subject: Re: Objects and Interactions: Separate Definitions Message-ID: <1991May21.064913.16149@netcom.COM> Date: 21 May 91 06:49:13 GMT References: <3999@motcsd.csd.mot.com> Distribution: comp Organization: Netcom - Online Communication Services UNIX System {408 241-9760 guest} Lines: 25 ]>>OK, let me expose my ignorance[1]. I'd like to see how object-oriented ]>>design works. Would you care to sketch the design for this? My naive ]>>model would be that a heap is an object and that it has add and remove ]>>methods to take objects of unspecified type and stick them into the heap ]>>in the right place. So where do the comparison and exchange procedures ]>>go? I see two alternatives[2]: (1) the heap object has compare and ]>>exchange methods that "know about" all of the types, figure out what's ]>>involved, and operate on the member objects or (2) the objects have ]>>methods that report their "comparable value" and size in canonical forms ]>>that a generic routine in the heap object can operate on. Neither of ]>>these makes me awfully happy. Why does 2 make you unhappy? This is a perfect example of what is called genericity in Ada and templates in latest-greatest C++. The basic principle is "separation of concerns": one program entity knows how to quicksort stuff (arbitrary stuff), but since it doesn't know a priori what the stuff being sorted is, the responsibility for providing a "<" operation belongs to the client providing the stuff. This is a first-rate way to achieve a high degree of reuse--one optimized and fully-debugged quicksort that can be used to sort any kind of object. -- **************** JIM SHOWALTER, jls@netcom.com, (408) 243-0630 **************** *Proven solutions to software problems. Consulting and training on all aspects* *of software development. Management/process/methodology. Architecture/design/* *reuse. Quality/productivity. Risk reduction. EFFECTIVE OO usage. Ada/C++. *