Testing Legacy Code & Avoid Mocking

Categories: Testing Legacy Refactoring Mocking

In reality, our jobs aren’t dealing with new code, but old crufty and evil code. How do we test such code, how do we get through it? How can we surgically take some of this bad code apart and make it testable.

This presentation looks at bad code and we talk about some of the strategies that we can do to diagnose, test, apply, and finally refactor to produce something that would promote some sanity in your development process. The content of this course is all in Java and Junit.

  • Effect Sketching

  • Parameterized Constructor

  • Parameterized Methods

  • Sprout Method

  • Sprout Class

  • Wrap Class

  • Wrap Method

  • Introduce Instance Delegator

  • Introducing Null

  • Subclass and Override

  • Sensing Variables

  • Tools including IntelliJ Refactoring Techniques