deliver:Agile 2018 has ended
Back To Schedule
Monday, April 30 • 10:20 - 11:05
Mastering Legacy Code: Preventing Bugs in Code You Can't Test (Arlo Belshee)

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

"I can't test this code because the design is awful. I can't refactor because I don't have tests. Yet it keeps having (and breeding) bugs. Now what?"
--- Everyone, everywhere
I've talked in the past about how this apparent catch-22 is resolved by a better understanding of the word "refactoring" --- that using a specific set of techniques allows defect detection and prevention even in untested --- or untestable --- code. Now I'm going to show you those techniques by applying them to some gnarly code.
This session is 75% live-coding, 25% talking. Most of the talking will be me asking you questions. So come if you want to think, want to get your hands dirty, and want to see specifics that you can try to apply immediately in your own code.
  1. Microtesting: understanding what the code does and deriving a spec.
    1. Resolve microtesting blocker: mechanically spot CQRS violations; resolve them via extract method + make method static.
    2. Resolve microtesting blocker: mechanically spot multiple responsibilities in a class; resolve them via extract method + make method static + introduce parameter object.
  2. Safeguarding: preventing bugs by eliminating hazards.
    1. Remove hazard: primitive obsession leads to inconsistent computation; resolve it via introduce parameter object + extract method + move method.

Learning Outcomes:
  • See a new way to test, with best features of both a unit test and an acceptance test.
  • Observe that testing this way induces design pressure, and use that to guide your design.
  • Spot and address the 2 most-common design obstacles to testing.
  • Understand that defects are not spontaneous; they can be prevented by addressing hazards.
  • Spot and address the #2 bug-creation hazard (#1 is naming, and that is already well-addressed in other work).
  • Pick which habits to take home and learn by applying on your code.

avatar for Arlo Belshee

Arlo Belshee

Team Craftsman, Legacy Code Mender, and Rabblerouser, Tableau Software
Arlo helps you change cultures in large organizations. He transitions hundreds or thousands of people at a time to full technical and cultural prowess in a way that sticks. More importantly, Arlo gives your company the ability to change its own culture. He seeks to be the last consultant... Read More →

Monday April 30, 2018 10:20 - 11:05 CDT
Lone Star F/G