Re: Speed of interfaces vs inheritance



Chris wrote:
In a particularly time-critical part of my app I need to call a method on an external class in a tight loop. The class can be different in different contexts. I've got two choices: create an interface and have the various different classes implement it, or create an abstract class and have the various different classes extend it.

I seem to recall, in years past, that the interface approach was slower. Is this still the case?

I guess that would be implementation specific.

I would expect them to be relative close in performance
due the similarity of what has to be done.

And if the method is actually doing some work the call overhead should
be minimal compared to what is happening inside the method.

A quick test with some randomly created code on what happen
to be my default Java (SUN Java 1.5 Win32) interface is
actually faster than abstract base class.

Arne

.



Relevant Pages

  • Re: Terminology
    ... > If an Abstract Base Class has only pure virtual functions, ... The language doesn't support the notion of Interfaces directly, ... > What makes an Interface differ from an Abstract Base Class? ...
    (comp.object)
  • Re: Template method pattern in Java ???
    ... doesn't see anything but the interface. ... I like being able to declare a private pure ... Abstract container defines the ability to contain and navigate through ... abstract base class also lays the foundation for doing it. ...
    (comp.object)
  • Re: Template method pattern in Java ???
    ... doesn't see anything but the interface. ... I like being able to declare a private pure ... Abstract container defines the ability to contain and navigate through ... abstract base class also lays the foundation for doing it. ...
    (comp.lang.java.programmer)
  • Re: Template method pattern in Java ???
    ... doesn't see anything but the interface. ... I like being able to declare a private pure ... Abstract container defines the ability to contain and navigate through ... abstract base class also lays the foundation for doing it. ...
    (comp.lang.java.help)
  • Re: Terminology
    ... > If an Abstract Base Class has only pure virtual functions, ... > functions, but no data member, is there a term for it? ... > What makes an Interface differ from an Abstract Base Class? ...
    (comp.object)