2 ms·
I don't understand how anyone can be fearless during refactoring. Suppose I refactor string search from the simple version (worst case time O(n*k)) to Knuth-Mor
by dalke 16y ago
I don't understand how anyone can be fearless during refactoring. Suppose I refactor string search from the simple version (worst case time O(n*k)) to Knuth-Morris-Pratt (worst cast time O(n+k)). The API is unchanged, so this is an excellent example of a refactoring. But the KMP implementation has so many more edge cases where I might make a mistake that I wouldn't be comfortable using only the tests uses to drive the simple version.
I would be happier with code coverage-based tests, or better, branch coverage-based tests. That would help tell me which parts of my new implementations need test cases, although it wouldn't be sufficient.
Would you really be fearless for this type of refactoring? And how does following TDD practices help out? It seems to make the fallacy that refactoring is trivial and therefore doesn't need additional testing.