Slides designed by Felix Grund, based on Paul Carter’s slides
Cohesion (SRP): High = Good
Coupling: Low = Good
Improving code structure without changing functionality
When refactoring, why can't we just update/alter the functionality at the same time?
Improving code structure without changing functionality
Fully working code base with tests!
Tests keep passing!
public class LittleClass {
public int doThingOne() {
int numTimes = 6;
int multiplier = 5;
numTimes += 1;
for (int i = 0; i < numTimes; i++) {
System.out.println(multiplier * i);
}
return numTimes;
}
public void doThingTwo() {
int occurrences = 3;
int timeser = 10;
System.out.println("Doing thing two");
for (int i = 0; i < occurrences; i++) {
System.out.println(timeser * i);
}
System.out.println("Doing thing two");
}
}
Run the code · adapt the test suite · add new test suites · code from the UI package should be moved out
Clone · re-organize using the diagram · start with Zoo, Animal and Stall · finally work on Receptionist