Re: Defining a constructor in an Interface
- From: Raymond DeCampo <nospam@xxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 18:36:10 GMT
Lee Fesperman wrote:
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.
Just because there are drawbacks, doesn't make it a bad idea. First of all, if such a thing were added to the language, interfaces wouldn't necessarily be required to specify a constructor signature. So everything that exists currently would still work exactly as it does. Second, if one were to use said functionality, one would have to be aware of the implications (as indicated in your post).
That said, I think we can live without this particular feature in the Java language.
Ray
-- XML is the programmer's duct tape. .
- References:
- Defining a constructor in an Interface
- From: Chris Berg
- Re: Defining a constructor in an Interface
- From: Chris Smith
- Re: Defining a constructor in an Interface
- From: Thomas Weidenfeller
- Re: Defining a constructor in an Interface
- From: Lee Fesperman
- Defining a constructor in an Interface
- Prev by Date: Re: Html download challenge
- Next by Date: Re: Default timezone changes out of nowhere?
- Previous by thread: Re: Defining a constructor in an Interface
- Next by thread: Re: Defining a constructor in an Interface
- Index(es):
Relevant Pages
|