Re: Defining a constructor in an Interface



Thomas Weidenfeller wrote:
>
> Chris Smith wrote:
> > That said, I don't think there's ever a good excuse for requiring a
> > constructor that takes parameters.
>
> Well, such a requirement, or lets better say nice-to-have feature, can
> come up when you want to have a 1:1 translation of your design model to
> an implementation. I perfectly understand (at least I think so) why
> things are as they are, but it would be nice to have it otherwise.

Nope, it's still a bad idea. A decent implementation is likely to want additional
arguments to its constructor. It pretty much kills multiple inheritance of interfaces
because of conflicting constructor requirements. If your implementation wishes to extend
another class with specific constructor requirements, you have no recourse.

There is more. Google for previous discussions on this.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
.



Relevant Pages

  • Re: Can Java Programmer Learn C++ Quickly?
    ... How could a method called from a constructor result ... >> in the VM attempting to invoke a method on an object that doesn't exist? ... > James spoke of calling a method of an object whose constructor had not ... Chris Smith - Lead Software Developer/Technical Trainer ...
    (comp.lang.java.programmer)
  • Re: Code in the Constructor
    ... "Chris Smith" wrote in message ... > serious definite problems because of its being in a constructor. ... some languages you can get "unusual" code behavior (and Java was mentioned) ...
    (comp.lang.java.help)
  • Re: Overriding Methods
    ... It's just unpredictable unless they are private, ... Chris Smith wrote: ... > I'd suggest that your mind is the one in error here, ... call public methods from the constructor as long as they are not ...
    (comp.lang.java.programmer)
  • Re: Can Java Programmer Learn C++ Quickly?
    ... Chris Smith scribbled the following: ... How could a method called from a constructor result ... >> in the VM attempting to invoke a method on an object that doesn't exist? ... "Outside of a dog, a book is a man's best friend. ...
    (comp.lang.java.programmer)