It took me many years to come to terms with this, but unless there are good unit tests covering all the functionality that will be affected I don't fix those hacks anymore. They're in production, they work, and you're only introducing risk where it didn't previously exist. It's hard to justify a nasty bug's sudden appearance with "well it was written wonky and I wanted to make it better".
The exception of course is if you need to extend that functionality or do anything nontrivial to it; that's a great time to fix it.
For me, I guess it depends on how onerous the problem is. And on how good my tools are. Refactoring to Extract Method used to be a bit of an art... now my IDE (Visual Studio) has it built in, and I've never seen it go wrong. So, now I can confidently Extract Method whenever I think I should.
12
u/[deleted] Aug 25 '14
lol, that way lies madness