Squashing the Bug

Java Case Study, Episode 11

By Robert C. Martin & Micah D. Martin

80 minAug 2015

The the help of Corey Boyle's son (and Corey to some extent) we managed to track down and kill that nasty threading bug.

Actually it was a bug in our tests, not in the production code. Indeed, production code would never have exhibited the problem because production code would have been synchronized by sending messages between the sockets. The problem we were having was that the tests bypassed the normal conversations.

The Clean Architecture begins to appear.

After fixing the bug, we started to break up the silly main program that was putting up the front page. We moved part of it to a CodecastSummariesController, and more to a CodecastSummariesPresenter, and a CodecastSummariesView.

We were driven to do this by the need to write a unit test for for the Controller. You'll see this in the video. Every time we tried to add something to the test, we decided to refactor the code a bit more to make it more testable.

You might infer that this was caused by a lapse in our TDD discipline. That's not quite true. It was really caused by taking test code and turning it into production code; and then partitioning that code into the desired architecture.

Anyway, If you've been wondering where the Clean Architecture was in the last 10 episodes; you'll begin to see it appear here.

The transition isn't complete. We've got more to do in the next episode. But it's coming.