Hey Folks! It’s a new site. If you see bad links or odd behavior, please contact me right away. Thanks! – GeePaw
 Home  Home  hom  Meet with GeePaw  Meet with GeePaw  mee  Work with GeePaw  Work with GeePaw  wor  Who's GeePaw  Who's GeePaw  who  Blog  Blog  blo  Contact  Contact  con

Refactoring Testless Code

 28. August 2017

refactoring in testless code is hard.

it’s the perfect demonstration of the manglish “agency” of code.

it is simply not possible to change testless code and guarantee you’ve done no damage. it’s one of the most delicate operations geeks do.there are principles, yes. there are tricksy techniques, too. but mostly, there is experience & judgment.the deep trick is to turn every mistake you make into a microtest that would keep it from ever happening again.

a key insight: never debug in legacy when you’re refactoring. the code that’s there is the code. it’s been shipping. it is right.

in that way, we can gradually pull ourselves out of testless legacy and into gradually increasing confidence.so. that’s all. be of good cheer. you get out of legacy the same way you got into it, one tiny step at a time.

oops. one more thought. noob TDD’ers won’t yet understand this, but the act of retrofitting microtests will reveal the correct design.

that is, a microtestable design is a good design, to some arbitrary epsilon. making it microtestable is fixing it. as you proceed with non-net-negative endpointless steps, the code will start to scream at you about the major refactorings that are needed.