Re: A Java "interface" declaration does not allow a constructor to be specified in it ...

From: Oscar kind (oscar_at_danwa.net)
Date: 11/09/04


Date: Tue, 9 Nov 2004 19:11:07 +0100

xarax <xarax@email.com> wrote:
>
> If Java supported full multiple inheritance (which is
> the implication of interface constructors), then there
> would be no need for interfaces; just use abstract classes
> in place of interfaces.

Which poses other problems. Imagine the following (but please bear with
the slightly off analogy):

abstract class Person has a non-abstract method "transport", that
implements walking.

abstract class MailDelivery has a non-abstract method "transport", which
implements mail delivery.

class MailMan extends both, and thus inherits the method transport from both
classes. For some reason, there is no reason to override it. Now please
think about these questions:
- Which one is inherited?
- If one is chosen automatically, what about dependencies in another
  superclass? The two methods may have an incompatible contract.
- If the method autometically becomes abstract, why? Abstract methods are
  always marked thus (either by the keyword abstract or by being defined
  in an interface).
- How do you select the transport method from Person? Extend the syntax
  again, with Person.super.transport()? It's hardly efficient to get a
  complicated, arcane syntax.

-- 
Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website
PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2


Relevant Pages

  • Re: Concrete class
    ... >> abstract class with ALL pure virtual functions. ... >> above philosophy then it means that your Shape is an interface. ... > of doing this is to keep the inheritance hierarchy at a low depths" is ...
    (comp.lang.cpp)
  • Re: Abstract class or interface?
    ... Abstract classes require and imply inheritance whereas interfaces do not. ... An abstract class would be used wherever it was important to enforce some ... aspect of the implementation an interface is used where only the agreement ... > derived classes can only inherit one abstract class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why I need Interface
    ... An abstract class is useful for providing some default or fundamental implementation. ... But it ties you to a specific base class, preventing you from inheriting any other base class. ... If you have no implementation you want to provide through inheritance, why lock yourself into it by using an abstract class rather than an interface? ...
    (microsoft.public.dotnet.framework)
  • Re: Confuesd about abstract class vs interface
    ... An abstract class is kind of like a new car. ... That's inheritance. ... An interface is a promise that your class will implement a set of methods ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ANN: Nexus Remoting coming soon
    ... For that there is now a 3rd post up explaining some advanced interface ... Transport architecture. ... On the server side they all use I/O completion ports ... have multiple threads on one client communicate simultaneously to ...
    (borland.public.delphi.thirdpartytools.general)