Skip to content

Priority test

Artyom Lobanov edited this page Jul 11, 2017 · 1 revision

Checks, that algorithms can move method even if method referenced from current class. In this situation methodA1 is called once from ClassA, and a lot of times from ClassB. So it's good idea to move it to ClassB.

Expected refactorings
Member Move to
ClassA.methodA1() ClassB
package priority;

public class ClassA {
    static void methodA1() {
    }

    static void methodA2() {
        methodA1();
        methodA3();
        methodA4();
    }

    static void methodA3() {
        methodA2();
        methodA2();
    }

    static void methodA4() {
        methodA2();
        methodA3();
    }
}
package priority;

public class ClassB {

    static void methodB1() {
        ClassA.methodA1();
        ClassA.methodA1();
        ClassA.methodA1();
        methodB2();
        methodB3();
        methodB4();
    }

    static void methodB2() {
        ClassA.methodA1();
        ClassA.methodA1();
        ClassA.methodA1();
        methodB2();
        methodB2();
        methodB1();
    }

    static void methodB3() {
        ClassA.methodA1();
        ClassA.methodA1();
        ClassA.methodA1();
        methodB2();
        methodB1();
        methodB5();
    }

    static void methodB4() {
        ClassA.methodA1();
        ClassA.methodA1();
        ClassA.methodA1();
        methodB2();
        methodB1();
        methodB5();
    }

    static void methodB5() {
        ClassA.methodA1();
        ClassA.methodA1();
        ClassA.methodA1();
        methodB2();
        methodB1();
        methodB4();
    }
}