Refactoring without tests is inherently unsafe, because of the risk of introducing bugs. As a professional, I would never take such risks. Therefore, I would only refactoring when I know I have good tests. In this way, TDD makes refactoring possible.I may not be representing his idea with perfect fidelity; for that I apologize.
My comments:
- There is a class of programming languages* for which there exist reliable refactoring tools. With these tools I can safely refactor even without tests.
- The reliable tools work by following a recipe. If a human follows the same recipe carefully, they'll get the same result. That would work in strongly typed languages that lack good tooling.
- Plenty of people who make their careers as programmers ("professionals") do sloppy work, but not those who are competent.
- The tests have to be good. If you only write tests when it's easy, they won't give you enough protection. The only way I know to get this kind of test coverage is if you strictly follow the Three Rules of TDD.
- When naive** TDDers aim for 100% test coverage, they go to extreme lengths in their tests, including bad mocks and test cases that don't correspond to any business value. These common problems lock down implementation, which makes refactoring far more difficult; the opposite of Jim's goal.
** most programmers
*** mocking is fantastic for Tell, Don't Ask, and problematic without TDA.
No comments:
Post a Comment