Implement method in all implementing classes
已回答
I have an interface that is implemented in 3 classes.
If I add a new method in the interface I have to separately
add the this method in each of the implementing classes.
Is there a way to make Idea to implement the new method in
all implementing classes, by one touch?
--
Daniel Moldovan
Level 7 Software
请先登录再写评论。
Please ask yourself: what should IDEA implement there? How should it
know?
Tom
On Thu, 5 Jun 2003 13:13:51 +0300, "Daniel Moldovan"
<d.moldovan@level7.ro> wrote:
>I have an interface that is implemented in 3 classes.
>If I add a new method in the interface I have to separately
>add the this method in each of the implementing classes.
>
>Is there a way to make Idea to implement the new method in
>all implementing classes, by one touch?
It should implement an empty method method in each class,
exactly the same way like it does now, but only for one class
at a time. And if someone it's has a short memory it should
modify the File Template for "implemented method body"
and put a "//TODO- implement me" in it.
"Thomas Singer" <thomas.singer@NOregnisSPAM.de> wrote in message
news:qt5udvcp0epujg4ugafst6l5cklvrt426j@4ax.com...
>
>
>
>
>
Does it really helps you? In 99,9% you need to modify the
autogenerated code, so what's the problem hitting Ctrl-I?
Tom
On Thu, 5 Jun 2003 13:26:51 +0300, "Daniel Moldovan"
<d.moldovan@level7.ro> wrote:
>It should implement an empty method method in each class,
>exactly the same way like it does now, but only for one class
>at a time. And if someone it's has a short memory it should
>modify the File Template for "implemented method body"
>and put a "//TODO- implement me" in it.
>
>
>
>"Thomas Singer" <thomas.singer@NOregnisSPAM.de> wrote in message
>news:qt5udvcp0epujg4ugafst6l5cklvrt426j@4ax.com...
>> Please ask yourself: what should IDEA implement there? How should it
>> know?
>>
>> Tom
>>
>>
>> On Thu, 5 Jun 2003 13:13:51 +0300, "Daniel Moldovan"
>> <d.moldovan@level7.ro> wrote:
>>
>> >I have an interface that is implemented in 3 classes.
>> >If I add a new method in the interface I have to separately
>> >add the this method in each of the implementing classes.
>> >
>> >Is there a way to make Idea to implement the new method in
>> >all implementing classes, by one touch?
>>
>
When I have 10 implementing classes it does.
It meas 10 Ctrl+I and 10 Enter keys.
"Thomas Singer" <thomas.singer@NOregnisSPAM.de> wrote in message
news:2q6udvkq1d821sfkaj3qekrlv13n6an9oc@4ax.com...
>
>
>
>
>
Thomas Singer wrote:
This way he could quickly test a scenario and later refactor the code.
BTW my generated method template includes TODO comment and
UnsupportedOperation exception, so the probabiulity of null object bugs
is reduced to minimum.
>This way he could quickly test a scenario and later refactor the code.
But you can forget relatively easily to implement it.
>BTW my generated method template includes TODO comment and
>UnsupportedOperation exception, so the probabiulity of null object bugs
>is reduced to minimum.
Sure? What if "accidently" your method is not called?
Tom
On Thu, 05 Jun 2003 13:52:36 +0300, dimiter <dimiter@blue-edge.bg>
wrote:
>Thomas Singer wrote:
>> Does it really helps you? In 99,9% you need to modify the
>> autogenerated code, so what's the problem hitting Ctrl-I?
>
>This way he could quickly test a scenario and later refactor the code.
>
>BTW my generated method template includes TODO comment and
>UnsupportedOperation exception, so the probabiulity of null object bugs
>is reduced to minimum.
Thomas Singer wrote:
what do you mean?
Consider the following use case:
You are writing an implementation of QuoteFeed object and you think that
you need another method in the interface.
If you have 10 different feeds, you'd have to implement 10 times the
given method just to be able to compile the source. Then you'd implement
it first only in one of the descendants, twst and 10 minutes later you
may realize that you want to remove it.
Agree that it's better to think before introducing changes in the
interface, but then you could code with notepad as well. The whole point
is being convenient.
Note that I don't care much about this issue because most of the time
when I have interface I have abstract base class as well, but it becomes
an issue in some cases (e.g. in J2ME each class adds a significant overhead)
-- dimiter
See http://www.intellij.net/tracker/idea/viewSCR?publicId=8475
--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"
"dimiter" <dimiter@blue-edge.bg> wrote in message
news:bbn7dn$op8$1@is.intellij.net...
>
>
>
Thomas,
If you are programming by intention and introducing operation when you need
them at the point of usage, you will encounter this problem. Since the
clients are dealing with the interface and not the implementations, there is
not way to incrementally refactor. If you want to get a green bar after each
implementation is completed you will have to stub that method in all the
others. Hence the problem.
In general Interfaces are making current refactorings really awkward. I do
not know yet how to formalize this into a request but I know something needs
to be done and it makes me VERY careful when to introduce Interfaces.
Jacques
"dimiter" <dimiter@blue-edge.bg> wrote in message
news:bbn8u6$rqn$1@is.intellij.net...
>
>
>
>
>
>
overhead)
>
>
>
I find a workaround: