Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!decwrl!stanford.edu!neon.Stanford.EDU!pescadero.Stanford.EDU!philip From: philip@pescadero.Stanford.EDU (Philip Machanick) Newsgroups: comp.object Subject: Re: Readability of Ada Message-ID: <1991Apr23.170144.22538@neon.Stanford.EDU> Date: 23 Apr 91 17:01:44 GMT References: <3878@ssc-bee.ssc-vax.UUCP> <20245@alice.att.com> Sender: news@neon.Stanford.EDU (USENET News System) Reply-To: philip@pescadero.stanford.edu Organization: Stanford University Lines: 47 In article , jls@rutabaga.Rational.COM (Jim Showalter) writes: I'm not sure what this whole thread has to do with comp.object, so maybe I'll only deal with the point that seems to fit the topic: |> I've been wanting to ask someone who purports to know the answer |> this question for over a year. |> |> Consider the shapes example. Suppose that the given example goes |> out in binary form, and arrives at my site, and I want to add a new |> shape. Suppose that the initial shapes were limited to triangles and |> squares. Suppose that I now add a Circle, which has a new method |> defined for it that does NOT apply to triangles or squares and which |> was never previously defined in the base class for shapes--radius. |> This method returns the radius as some floating point number from 0 |> to whatever. |> |> Now, I want to take a heterogeneous list of shapes, including triangles, |> circles, and squares, and I want to iterate over the list and print |> out all of the radii. |> |> How do I do this? I can't get elements out of the list and call |> the Radius method on all of them, because not all of them HAVE such |> a method defined. I can't add the new method to the base class (with |> a null implementation as the default for those shapes for which it |> is a meaningless operation) because the base class is in binary. I |> can't ask the shapes to tell me their Kind because there is no such |> operation defined on them in C++. |> |> It is my claim that solving this problem in C++ results in a solution |> that is every bit as messy as simply using a discriminated record |> and an enumeration type in Ada--and Ada doesn't HAVE inheritance. All this example says is that object-oriented programming doesn't solve the design problem. Everyone knows that designing general class libraries is non-trivial. This is not news. Everyone knows that Ada doesn't have support inheritance (except in a very weak sense, through derived types). You've found an example where there is no obvious way of using inheritance. Does this invalidate the concept? In the early days of structured programming, the literature teamed with examples of strange loops you could only code with gotos. Did this stop the structured programming movement? For the record: I used Ada before I used C. I need an object-oriented language, and Ada isn't one. Maybe C++ is a messy compromise, which attempts to patch over a lot of outdated design decisions, but its object-oriented features are a lot better than Ada's. -- Philip Machanick philip@pescadero.stanford.edu