Pivot Points
In the best large scale refactorings I've done, I've found pivot points.
Often you must change an API or how data works in many tests or places. If you change the behaviour and then the tests, it can take a long time to do the redesign by refactoring. In this case you need to find a pivot point.
A pivot point represents a small bit of code that allows you to change one behaviour to another in a few lines of code.
Basic steps are:
1) You refactor all your code to the pivot point. (You preserve old behaviour - all your tests pass) You should be able to do this incrementally, checking on often.
2) You make your underlying change. - all your tests should now fail using the old implementation.
3) You change the pivot point to produce the new behaviour.
Tada, all your tests pass.
By introducing one or more pivot points you can change behaviour incrementally.
The blog I'll write next shows how this works.
0 Comments:
Post a Comment
<< Home