Re:A Short Cautionary Tale About Refactoring
by NohatCoder on Sunday March 21, 2021 @05:47AM
(#26529292)
Try to actually design the test that would have caught this. There is no way in this universe that one can blindly rely on tests when refactoring.
[ Parent
| on HN ]
Re:A Short Cautionary Tale About Refactoring
by alkonaut on Sunday March 21, 2021 @06:55AM
(#26529536)
Code that is obvious is better. That’s also difficult here (You’d for example make a function call of image_that_should_work_offline(..)” that simply returns its argument, but that’s perhaps a bit contrived). So the second best is simply a comment.
// Image inlined because error may be due to dropped connection
You don’t have to have tests to prevent bad refactoring. 100% test coverage isn’t realistic for most code bases (or isn’t even a net positive in many cases).
self-documenting code, or tests, or comments would have saved the situation. You don’t need to design a test in this case. A one line comment that takes five seconds to write is enough.