Quickest way to add interface and implementation member

Lets say I have a class that implements several members. Using R#, what is
the quickest way to add a member to the class and have it added to one of
the interfaces?


10 comments
Comment actions Permalink

Hello flipdoubt,

I think that Pull Members Up refactoring is what you are looking for.
You may also want to read this blog: http://resharper.blogspot.com/

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


f> Lets say I have a class that implements several members. Using R#,
f> what is the quickest way to add a member to the class and have it
f> added to one of the interfaces?
f>


0
Comment actions Permalink

I think that Pull Members Up refactoring is what you are looking for.


Thanks. Sometimes I get confused between PullUp and PushDown.


0
Comment actions Permalink

Hello flipdoubt,

May be we need to rename them as "Pull to Base" and "Push to Derived", to
avoid confusion?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


>> I think that Pull Members Up refactoring is what you are looking for.
>>
f> Thanks. Sometimes I get confused between PullUp and PushDown.
f>


0
Comment actions Permalink

Hello flipdoubt,

May be we need to rename them as "Pull to Base" and "Push to Derived",
to avoid confusion?


Sounds good. Perhaps you should just rename them "Move to base"/"Move to
derived" -
I really don't think the push/pull metafor adds any clarity.
Pushing a method down to the base class is just as logical to me - it deponds
on how you layout the class hierarchy in your head.

Of course, the problem with renaming it to "Move" is that you break the connection
to the standard refactoring names, e.g. http://www.refactoring.com/catalog/pullUpMethod.html


0
Comment actions Permalink

Hello Niels,

It's not always a move. If you "pull" member up to interface, member is not
actually moved, instead interface member is created, but the member with
its body is left in the original type.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


>> Hello flipdoubt,
>>
>> May be we need to rename them as "Pull to Base" and "Push to
>> Derived", to avoid confusion?
>>
NU> Sounds good. Perhaps you should just rename them "Move to
NU> base"/"Move to derived" - I really don't think the push/pull metafor
NU> adds any clarity. Pushing a method down to the base class is just as
NU> logical to me - it deponds on how you layout the class hierarchy in
NU> your head.
NU>
NU> Of course, the problem with renaming it to "Move" is that you break
NU> the connection to the standard refactoring names, e.g.
NU> http://www.refactoring.com/catalog/pullUpMethod.html
NU>


0
Comment actions Permalink

May be we need to rename them as "Pull to Base" and "Push to Derived",
to avoid confusion?


Wow! "Pull to Base" and "Push to Derived" makes things much more clear. I
would be happy to see that renamed.


0
Comment actions Permalink

Please don't. I'm getting tired of each refactoring tool having different names for some of the most fundamental refactorings.

If you're going to rename it all, please use the naming established by the seminal work on refactoring, that being Fowler's Refactoring, which calls these Pull Up * and Push Down *.

If there's an even more well-known authority on refactoring that has a different name, I'd love to be pointed towards it.

0
Comment actions Permalink

(where * is of course replaced by "Property", "Method", "Constructor Body", etc. as appopriate)

0
Comment actions Permalink

+1 for following Fowler's namings.

There is a difference between poorly named refactorings and a developer not having class hierarchies the standard way around in their head.

I am usually in the second camp, but as I use these refactorings quite regularly, the class hierarchy is slowly turning itself the right way up in my head :)

Pull Up / Push Down are very well named refactorings.

0
Comment actions Permalink

I agree with your point except for "Pull Up / Push Down are very well named
refactorings." There is room for improvement, as perfect as Martin Fowler
may or may not be. If there wasn't room for improvement, we would still be
writing in assembly language, no?

Can we compromise by keeping your canonical names and just being more explicit
with "Pull Up to Base" and "Push Down to Derived"? That doesn't hide Fowler's
meaning: it ampifies it.

+1 for following Fowler's namings.

There is a difference between poorly named refactorings and a
developer not having class hierarchies the standard way around in
their head.

I am usually in the second camp, but as I use these refactorings quite
regularly, the class hierarchy is slowly turning itself the right way
up in my head :)

Pull Up / Push Down are very well named refactorings.



0

Please sign in to leave a comment.