comp.lang.ada
 help / color / mirror / Atom feed
From: James Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: Another good URL for all you C++ haters
Date: Thu, 06 Sep 2001 16:57:52 GMT
Date: 2001-09-06T16:57:52+00:00	[thread overview]
Message-ID: <3B97AB21.923D6482@worldnet.att.net> (raw)
In-Reply-To: 3b97914c.4153792@news.demon.co.uk

John McCabe wrote:
> 
> On Wed, 05 Sep 2001 21:49:24 GMT, James Rogers
> <jimmaureenrogers@worldnet.att.net> wrote:
> 
> > Java fans proclaim a lack of separation of
> >interface and implementation to be an advantage because you have
> >less code duplication.
> 
> In my experience, Java fans claim that the Interface/Implementation
> separation feature of OO is provided by the Java Interface structure
> and Class structure (i.e. the Interface provides the Interface, and
> the Class provides the Implementation). This seems a very high level
> viewpoint corresponding to something like a pure virtual class (C++),
> or abstract tagged type (Ada) rather than what Ada programmers often
> see as the separation, i.e. the package spec/body.
> 
> Personally I believe it is a combination of both.

Java also allows the definition of abstract classes. They have the
expected restrictions such as not being able to create an instance
of an abstract class. Java interfaces are treated differently by the
language. In Java you can extend (inherit from) only one class,
producing single inheritance similar to Ada's. On the other hand,
you can implement any number of interfaces, and interfaces may
inherit from other interfaces.

In many cases you can program Java entirely without the use of
interfaces. Exceptions to this include the use of event handlers.
Java event handlers are commonly used in GUIs and the reusable
code modules called Java Beans.

Note that, for Java Beans, only the event handler interface is
required. There is no interface requirement for the get and set
methods for Bean properties. Common practice, then, provides only
partial separation of interface and implementation for Java Beans.
Builder tools that use Java Beans employ introspection to evaluate
Bean properties. In this case the implementation must report its
interface at run time. 

Furthermore, there is no way to specify a constructor in a Java
interface. Thus, even if you are diligent about building your Java
classes from interfaces, you must still omit critical parts of the
class definition.

Why is introspection not as good as explicit separation of 
interface and implementation? Not every program uses introspection.
Furthermore, introspection is a run-time activity. This means that
compilers must have access to full implementation code, even though
Java exclusively uses a shared library (aka dll) model for linking.
There is no way in Java to perform an early compilation of just the
interfaces, as can be done in Ada. Lack of separation inhibits large
team development.

Jim Rogers
Colorado Springs, Colorado USA



  reply	other threads:[~2001-09-06 16:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-05 11:08 Another good URL for all you C++ haters Chris M. Moore
2001-09-05 12:22 ` Gerhard Häring
2001-09-05 13:43   ` Ted Dennison
2001-09-06 12:04     ` Chris M. Moore
2001-09-06 19:12       ` Robert Dewar
2001-09-07 10:30         ` Chris M. Moore
2001-09-07 11:12           ` Larry Kilgallen
2001-09-08  9:37           ` Florian Weimer
2001-09-05 14:43 ` James Rogers
2001-09-05 21:25 ` Florian Weimer
2001-09-05 21:49   ` James Rogers
2001-09-06 15:33     ` John McCabe
2001-09-06 16:57       ` James Rogers [this message]
2001-09-07 17:54   ` Tucker Taft
2001-09-08 10:11     ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox