TDD is an effective practice for writing code, but what if the code is in place already? Worse yet, what if there are no tests (or very few tests) checking the behavior of the code? This is a situation often faced by software engineers as they inherit "legacy code." Legacy code carries a stigma of being difficult to change and/or maintain. This is usually due to the fact that the logic that it was designed to provide was not passed to the engineer who becomes responsible for the code. In that sense the true behavior of the legacy code is unknown, and it becomes a black box that cannot be altered due to fear of repercussions.
This fear does not have to exist, and legacy code can be adopted and improved through refactoring practices. This lab will walk you through the process of adding "characterization tests" to code that has been provided for you, and then guide you through several refactoring cycles to make the code easier to understand and maintain. Through this, you will learn and practice effective refactoring techniques.