Re: Template method pattern in Java ???
From: Avner Ben (avner_at_skilldesign.com)
Date: 02/23/04
- Previous message: Thomas Kreiss: "Re: priority queue"
- In reply to: Steven Wurster: "Re: Template method pattern in Java ???"
- Next in thread: Steven Wurster: "Re: Template method pattern in Java ???"
- Reply: Steven Wurster: "Re: Template method pattern in Java ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 23 Feb 2004 10:04:07 +0100
Steven Wurster wrote:
> [snip]
> From the client perspective, all classes are pure interfaces. The
> only caveats being that contracts may refer to other routines and it
> is possible to figure out how some routines are coded just from the
> contract; and the fact that abstract classes cannot be instantiated.
> But, in general, the client does not and should not care whether or
> not a class has implementations for any of its routines. Just code to
> the interface.
>
> From the descendant programmer perspective, this is a different issue.
> It matters which routines are abstract because those will have to be
> implemented should the programmer wish that specific descendant to be
> instantiated. It is an orthogonal issue. The catch here is with
> inheritance and polymorphism:
Perhaps we need two kinds of interface: usage interface and extension
interface.
>
> Java, Eiffel, and I'm guessing C#, treat every routine as potentially
> polymorphic. C++ of course does not, and you have to ask for dynamic
> binding, and have the foresight that it will be needed.
In C#, as in C++, a method is non-virtual by default. I am not happy
with that decision.
But Eiffel
> also allows for the inheritance of non-purely abstract classes. What
> this means is that the descendant programmer has freedom to add
> polymorphism to any class, and at the same time inherit from any other
> class. Level of abstraction is irrelevant. This is different in Java
> and possibly C#, where polymorphism can be added to any class, but
> inheritance from another class at the same time is limited to purely
> abstract ones (interfaces in the Java world). This severely limits
> the concept of inheritance. That is my entire argument here. Java is
> flawed in this notion.
In C++, you can inherit from any class, abstract or otherwise and to my
best knowledge, in Java, too. Java distinguishes between extends (base
class) and implements (interface). C# does not. In C++ and C# you can
use objects polymorphically only through messages predefined to be virtual.
> [snip]
> I'm not sure what you mean by repeating of the conditions? You mean
> he repeates the pre and postconditions? This is nothing new. Eiffel
> does this for you, automatically no less. Eiffel also automatically
> takes care of joining multiply inherited routines when one is abstract
> and the other isn't. For the cases where multiply inherited routines
> are both implemented, you have to select which one is used "up the
> tree", if you will, while you have full choice over how to define the
> new routine in the new class.
>
We speak about documentation here - there is no formal DBC support in
C++. Although Stepanov never mentions either Eiffel or B. Meyer, they
seem to be at least influenced from the same source.
Avner.
- Previous message: Thomas Kreiss: "Re: priority queue"
- In reply to: Steven Wurster: "Re: Template method pattern in Java ???"
- Next in thread: Steven Wurster: "Re: Template method pattern in Java ???"
- Reply: Steven Wurster: "Re: Template method pattern in Java ???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|