News for hackers. Stuff that matters.
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.

There are no comments on this comment yet.