Article View: comp.lang.java
Article #13Re: C++ and Java
From: Bill Burcham
Date: Tue, 10 Oct 1995 20:11
Date: Tue, 10 Oct 1995 20:11
59 lines
3117 bytes
3117 bytes
branzcgp@branz.org.nz (Christopher Price) wrote:
>On Sun, 08 Oct 1995 03:00:48 -0600, Nelson Yu
><nyu@gpu.srv.ualberta.ca> wrote:
>>
>[snap snap]
>
>>Albeit you can't compare OWL with AWT, which has fairly
>>complicated hierarchy that uses multiple inheritance extensively,
>>'cause they are suited for different purposes.
>
>Many of the methodology gurus have stated (sorry I'm not chasing the
>reference here) that single inheritence leads to poor design.
>
>This axiom (I've taken it to heart) is one foundation for good OO
>technology of the future for complex projects.
<<munch>>
OK I'll bite ;) Java supports multiple inheritance of interface, but only
single inheritance of implementation (class). At the design level, you can
treat this a multiple inheritance (and _implement_ multiply inherited
interfaces using delegation).
In a statically-typed OO language, you have to have either:
* parameterized types (templates)
-- or --
* interfaces (or protocols)
..to make up for losing runtime method dispatch.
Templates are cool because they allow you to use _existing_ classes in
interesting ways without requiring changes to those classes (changes like
adding a mixin base-class, or specifying an additional interface to implement
or protocol to adopt).
Interfaces are cool because they are not templates (grin). Seriously though,
current C++ language systems (and build systems) are notoriously bad at
"doing" templates. This becomes a real problem when we start to use STL and
build our systems in an STL style (templates everywhere).
So, I will agree that in the _absence_ of templates and interfaces,
single-inheritance leads to poor design (because there are certain things you
simply cannot do, and because reuse often requires changes to existing
classes).
With templates, however the need for multiple inheritance goes away. I don't
have to use MI to use STL for instance. I don't have to use MI to
_implement_ STL. With interfaces (protocols) MI (of interface -- not
implmentation) is possible and useful. The one problem being that it is
sometimes necessary to subclass an existing class just to add an interface
(or worse yet, we sometimes actually add the new interface to the existing
class). Whew!
--
Bill Burcham billb@sunquest.sunquest.com
520.733.6361 (Work)
Sunquest Information Systems 520.733.6602 (Fax)
Technical Details
Message-ID:
<45ek2d$mog@odin.sunquest.com>Path:
arc1-ca.pugleaf.net!news.sunquest.com!newsReferences:
<4535bv$cfr@susscsc1.rdg.ac.uk> <453vg1$d7j@scapa.cs.ualberta.ca> <4565t8$u5q@hopi.gate.net> <30779340.64E4@gpu.srv.ualberta.ca> <45ceei$h3g@st-james.comp.vuw.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.sunquest.com!news From: Bill Burcham <billb@sunquest.sunquest.com> Newsgroups: comp.lang.java,comp.lang.c++ Subject: Re: C++ and Java Date: 10 Oct 1995 20:11:57 GMT Organization: Sunquest Information Systems, Inc. Message-ID: <45ek2d$mog@odin.sunquest.com> References: <4535bv$cfr@susscsc1.rdg.ac.uk> <453vg1$d7j@scapa.cs.ualberta.ca> <4565t8$u5q@hopi.gate.net> <30779340.64E4@gpu.srv.ualberta.ca> <45ceei$h3g@st-james.comp.vuw.ac.nz> NNTP-Posting-Host: binky.sunquest.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 1.2N (Windows; I; 32bit)