Is there a way to move a method from a class A to other B where A does not depends upon B?

Hello,

Suppose:

class A {

     private C other;

     public void methodA(){
          //do stuff
     }

     ...
}


class B {
     ...
}

I wanna move methodA from A to B, but it seams to be impossible. The only move operation possible is from A to C. Is that true? If so, why?

Thanks in advance,
Vitor

2 comments

because it will produce non-valid code?

initial code compiles:

A a = new A();
a.methodA();


after refactoring:

A a = new A();
a.methodA(); -- compile error, no such method


if method is static then it's ok:

A.methodA();

will become

B.methodA();
0

humm, i gess there is no easy way to put the code in a valid state given those conditions...

0

Please sign in to leave a comment.