Re: same old question: interface Vs. Abstract class




zeroone wrote:
> Hi all,
>
>
> I m a C++ programmer basically & recently got into JAVA tech.
>
> I have 2 doubts:

Snip 1 ...

>
> Suppose I m damn sure that my kid concrete class objects will have
> different behaviour for same request issued and all methods will be
> clubed within one dady ABC. Then I think I should use ABC only over
> interface for speed optimization.

Speed optimization? I take it you mean the speed of execution of the
eventual product. Have you read somewhere that a subclassed object runs
faster than an object that implements an interface? I am unaware of any
such differentiation.

That aside, given the certainty of your design above, I would see no
reason to favour ABC over an interface except for the reason I usually
read in such circumstances: if any of your subclasses' methods have
common, default behaviour, then ABC is the better choice, as the ABC
can describe the default behaviour, rather than having identical
methods in each of the subclasses.


>
> Here is some sample code that I thought will help u guys understand
me
> better.

Snip 2 ...

>
>
> -----------
> SECOND
> -----------
>

Snip 3 ...

>
> In C++ its MI provided programmers dont do stupidty.
>
> How will one phrase the same in JAVA. Its obvious I define interfaces
> in C++. I write ABC with all the stuff virtual.

I'm not 100% what you mean by, "How will one phrase the same in JAVA;"
do you mean, "How do you implement such multiple-inheritance in Java?"
I presume you're not asking that, as you know Java has only
single-inheritance; and that the only way to implement the above is
with at most one ABC per class, and all other mixin functionality with
interfaces.

Hmm ...

..ed

www.EdmundKirwan.com - Home of The Fractal Class Composition.

.



Relevant Pages

  • Re: Why ABCs make bad Interfaces
    ... > equivalent to an Abstract Base Class (ABC). ... > because it is common practice to implement an interface using ABC's. ... To convert an object to its interface, you return a fat pointer ... The NaiveInt constructor has to set up the vtables, ...
    (comp.object)
  • Re: Declaring a Constructor in an Interface?
    ... ABC: ... Interface: ... >> static void SpeedTestInterface ... > implementing IFoo. ...
    (microsoft.public.dotnet.languages.csharp)
  • Problems with extant SW for emailing
    ... Problem with Google Mail and Ubuntu ... example 1) "ABC List" in the subject line and if anybody on ABC in the ... an Internet-connected interface, then it can indeed receive mail. ... Modify settings or unsubscribe at: ...
    (Ubuntu)
  • Re: Problem with Google Mail and Ubuntu
    ... example 1) "ABC List" in the subject line and if anybody on ABC in the ... listens on port 25 and the interfaces you specify. ... an Internet-connected interface, then it can indeed receive mail. ... via the file system to the local mail ...
    (Ubuntu)
  • Why ABCs make bad Interfaces
    ... the differences between Abstract Base Classes (ABC) and Interfaces: ... because it is common practice to implement an interface using ABC's. ... to all of the neccessary vtables and lookups. ...
    (comp.object)