Mob Programming Refactoring Experience: Restoring Missing Domain Objects
The article recounts a 2009 GoCD team mob‑programming session where developers collaboratively refactored a module, identified missing domain objects, applied a strong refactoring environment and automated tests, and transformed flawed Java code into a cleaner, domain‑driven design.
In 2009 the GoCD team experimented with what is now called mob programming , a practice where the whole team works together on the same task, at the same time, in the same space, and on the same computer.
Mob programming, as defined on Wikipedia, is similar to pair programming but involves the entire team sharing a single keyboard, screen, and development environment.
The session lasted about two hours, during which the team gathered around one computer and a projector to refactor technical debt in a module by re‑introducing a missing domain object, making the code simpler and easier to maintain.
Benefits observed: everyone stayed on the same page, understood the purpose of the change, and could immediately apply the new domain concepts to future work.
Two prerequisites made the session successful:
A powerful refactoring‑capable development environment.
Comprehensive automated tests.
The team identified three concrete outcomes:
Derived a new refactoring technique by analyzing object lifecycles to locate missing domain objects.
Defined criteria for recognizing technical debt when code works but becomes cumbersome to modify as features grow.
Produced before‑and‑after code examples illustrating the removal of an inappropriate service injection.
Original (flawed) Java code:
public class A {
@Autowired private BService b;
public A() {}
public doWork() {
// ...
C c = b.doSomething();
// ...
}
}The analysis revealed that class A (a domain object) incorrectly depended on BService . Through a series of Q&A steps the team uncovered missing objects D and E , clarified responsibilities, and introduced a new EService to provide D .
Refactored code after the mob session:
public class A {
public A() {}
public void doWork(D d) {
d.doXXX();
}
}
public class D {
public D() {}
public boolean doXXX() {
// implementation
return m == null ? true : false;
}
}
public class EService {
public EService(...) {}
public D findDByID(int id) {
// lookup logic
return d;
}
}Calls were updated to use the new service: a.doWork(eService.findDbyID(id));
The refactoring resulted in clearer responsibilities, reduced coupling, and a more maintainable codebase, demonstrating how mob programming can accelerate technical debt reduction.
Continuous Delivery 2.0
Tech and case studies on organizational management, team management, and engineering efficiency
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.