T O P I C R E V I E W |
John_H_Bergman |
Posted - Jul 26 2006 : 1:20:02 PM I'd like to refactor a specific method to an interface, if te object implements more than one interface, it should ask which one to put it in. (refactor on the method/property)
It'd be nice if I could take all the public methods/properties of an object and refactor it into an interface. (refactor on the class name) |
9 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Aug 19 2006 : 09:04:10 AM i have found a case mentioning push up, so i have mentioned this thread there, so hopefully we won't loose track of this.
case=1121 |
John_H_Bergman |
Posted - Aug 18 2006 : 10:56:08 AM The only trick with push-up into an interface is that you would have to remove the public and all of the method body.
using your example
class Foo : BaseBar, IFeline { /// <summary> /// Some meaningful description /// </summary> public void bar() { // Do some C# stuff } }
would be public interface IFeline { /// <summary> /// Some meaningful description /// </summary> void bar(); }
or, if you wanted to carry this further and push it up as an abstract method (also useful)
public class BaseBar /// <summary> /// Some meaningful description /// </summary> public abstract void bar();
}
Then of course, you could push up the whole method. and remove it from the source class.
So in my mind, there are really 3 options
Push up to interface Push up as abstract method Push up with implementation
|
feline |
Posted - Aug 13 2006 : 1:14:12 PM once push up and push down appear (assuming they ever appear) i am sure creating interfaces will come up again. it is possible we will decide against this specific idea, but instead make the building blocks available. this is the general design behind the current refactoring code, to provide small and well defined operations that can be chained together by the user to create the desired result. |
obricker |
Posted - Aug 12 2006 : 5:20:14 PM I was thinking that it would be easy once push up method was implemented.
I would have put a smiley on the comment buit they are |
feline |
Posted - Aug 03 2006 : 6:57:55 PM push up method has been discussed on the forum, and we thought up various situations where it could be tricky.
creating a whole new interface like that... it is an interesting idea, but it certainly sounds more complex and involved than push up method. "easy" is not a word i would use personally!
*considers*
once the interface, or parent class (since the idea is the same) has been created all you are really talking about is some form of push up method run multiple times.
for now we probably need to wait and see what happens about push up method. currently we are working on fixing as many of the outstanding bugs as possible, both in the new refactoring code, and other, more general bugs. |
obricker |
Posted - Aug 03 2006 : 11:21:06 AM Having VA " add Bar to the Interface" (IFeline in this case) in this way seems a lot like Push Up Method. It would just replace the parent implementation with a declaration that the method is abstract and leave the current implementaion in place.
I would like the option of "Create Interface" which would present me with the methods first defined by the target class and let me choose which one to take. Then a class would be created with these methods as abstract. The original class would then inherit from this Interface class. Easy, right?
OB
|
feline |
Posted - Jul 31 2006 : 5:22:36 PM i have the feeling i don't quite follow what you are asking for here. i never really studied interfaces in C#, but i think i understand the basic idea.
if you have the class:
class Foo : public IFeline
{
public:
void bar();
}
(i have guessed at the syntax for interface, for ease )
you want to say "add bar to the interface"? or are you after something else? |
John_H_Bergman |
Posted - Jul 31 2006 : 4:30:04 PM No, I am asking about refactoring to an interface in c#, although the baseclass idea would be useful too :-) |
feline |
Posted - Jul 29 2006 : 10:22:08 AM *um*
are you talking about getting VA to modify a base class from an instance of the derived class? this has been discussed on the forum in broad terms, and the idea is interesting, but runs into difficulties with multiple inheritance, etc. |