3 ms·
This hits on an important point I don't see discussed much and certainly not addressed as important. Debugging is (one of) the most important UX aspects of your
by UglyToad 6y ago
This hits on an important point I don't see discussed much and certainly not addressed as important. Debugging is (one of) the most important UX aspects of your code.
Similar to code being read a lot more than written, you should prioritise debugger user experience over other aspects. One thing I try to do is have a temporary variable called result in many places and immediately return that on the next line. Though in some versions of Visual Studio you can faff about and add a watch with some magic name ($return Value?) to inspect the return value its much easier to have an easy location to chuck a breakpoint. Similarly chaining method calls or LINQ should be broken up with easy inspection variables so you can easily verify the state.
It seems like needless verbosity but when prod is broken and you desperately need to fix something you'll be glad of it.
- lonelappde 6y agoWriting extra error prone code just to make easier debugging seems like a bad trade-off. Better to learn how to use a debugger, and check preconditions, and log state changes, and write tests.