3 ms·
Rewriting probably even more risky. In my experience the kind of change that is needed to make the function testable rarely introduces bugs. Rewriting the funct
by quonn 2y ago
Rewriting probably even more risky. In my experience the kind of change that is needed to make the function testable rarely introduces bugs. Rewriting the function will likely introduce bugs, especially if bugfixes have been done on the original function before.
- imiric 2y agoI agree that rewriting is riskier, but refactoring the function to make it testable can indeed introduce bugs. The thing is that you'd never be sure of it, since you don't have tests to prove how it should've worked initially. I mean, if the function is trivial, it's easier to change it without affecting its behavior, but sometimes this is not the case. So having _some_ tests, even if they're not unit tests, makes this a bit safer.