[jdom-interest] Factories

Alex Rosen arosen at novell.com
Mon Mar 1 07:29:41 PST 2004


>>>> "Chris B." <chris at tech.com.au> 2/29/2004 5:10:48 AM >>>
>
>Alex Rosen wrote:
>
>>I vote for class or abstract class. Here's part of my notes from one
of
>>the presentations at EclipseCon a few weeks ago.
>>
>>"He advised that you shouldn't create interfaces that you expect
users
>>to implement - use abstract classes instead, for forward
compatibility.
>>  
>>
>
>True, but you lose all the good things about interfaces - the ability
to 
>have multiple "inheritance".

Yes, though that's much more of an issue with "mixin" types. Things
like Comparable, Cloneable, Listeners, etc. all need to be interfaces
because you commonly want to "mix" them in to your existing class, whose
primary purpose is something else (and therefore its may already inherit
from another class). But how often will you want to make your existing
class also implement JDOMFactory? I'm not saying that it'll never
happen, but much more commonly you'll use an auxiliary class in this
particular situation.

>Why not have both? With suitable warnings 
>about the dangers of using the interface instead of the abstract
class?

Interesting idea. If you're OK about breaking the code of people who
implement the interface and don't use the abstract class, that's OK.
Often, though, breaking any existing code is verboten, even if people
were warned.

That said - I don't feel strongly about it in this case. Getting 1.0
out the door is more important.

Alex




More information about the jdom-interest mailing list