Book Image

Test-Driven Java Development

Book Image

Test-Driven Java Development

Overview of this book

Table of Contents (17 chapters)
Test-Driven Java Development
About the Authors
About the Reviewers
Refactoring Legacy Code – Making it Young Again

Legacy code

Let's start with the definition of legacy code. While there are many authors with different definitions such as lack of trust in your application or your tests, code that is no longer supported, and so on, we like the one created by Michael Feathers the most:


Legacy code is code without tests.

The reason for this definition is that it is objective: either there are or there aren't tests.

 --Michael Feathers

How to detect legacy code? Although legacy code usually frequents bad code, Michael Feathers exposes some smells in his book Working Effectively with Legacy Code by Dorling Kindersley (India) Pvt. Ltd. (1993).


Code Smell

Smells are certain structures in the code that indicate violation of fundamental design principles and negatively impact design quality.

Code smells are usually not bugs—they are not technically incorrect and do not currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing...