O'Reilly logo

Beyond Legacy Code by David Scott Bernstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring Techniques

As you clean up code and it becomes more testable, it also becomes simpler to extend and drives down the cost of future changes. Here are some techniques I use to refactor code.

Generally, refactoring legacy code starts out at the feature level, so there is some observable behavior that you can write a pinning test against.

Pinning Tests

A pinning test is a very coarse test. It may test a single behavior that takes hundreds or thousands of lines of code to produce. Ultimately you want more tests that are smaller tests than this, but start by writing a pinning test for overall behavior so that at least you have some support in place. Then as you make changes to the code, you rerun the pinning test to verify that the end-to-end ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required