-
Notifications
You must be signed in to change notification settings - Fork 3
MoveTogether test
Mikhail Pravilov edited this page Jul 3, 2018
·
2 revisions
Checks that algorithms move methods with their dependencies. In this situation methodB1 depends on methodB2, which has no dependencies except methodB1. So it's good idea to move them together.
Member | Move to |
---|---|
ClassB.methodB1() | ClassA |
ClassB.methodB2() | ClassA |
package moveTogether;
public class ClassA {
static int attributeA1;
static int attributeA2;
static void methodA1() {
attributeA1 = 0;
methodA2();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
}
static void methodA2() {
attributeA2 = 0;
attributeA1 = 0;
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
}
static void methodA3() {
attributeA1 = 0;
attributeA2 = 0;
methodA1();
methodA2();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
}
static void methodA4() {
attributeA2 = 0;
attributeA1 = 0;
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
}
static void methodA5() {
attributeA1 = 0;
attributeA2 = 0;
methodA1();
methodA2();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
ClassB.methodB1();
}
}
package moveTogether;
public class ClassB {
static int attributeB1;
static int attributeB2;
static void methodB1() {
ClassA.methodA1();
ClassA.methodA1();
ClassA.methodA1();
ClassA.methodA1();
ClassA.methodA2();
ClassA.methodA2();
ClassA.methodA2();
ClassA.methodA2();
methodB2();
methodB2();
methodB2();
methodB2();
methodB2();
methodB2();
methodB2();
methodB2();
}
static void methodB2() {
methodB1();
methodB1();
methodB1();
methodB1();
methodB1();
methodB1();
methodB1();
methodB1();
}
static void methodB3() {
attributeB1 = 0;
attributeB1 = 0;
}
}