Look Out for Bugs
matklad.github.io
Look Out for Bugs
1–10 of 42 posts
Re: Look Out for Bugs
#2Re: Look Out for Bugs
#3Re: Look Out for Bugs
#4Does this person also identify performance issues by reading the code? This is completely impractical.
Re: Look Out for Bugs
#5Re: Look Out for Bugs
#6[flagged]
1. Code defensively, but don't spend too much time on handling error conditions. Abort as early as possible. Keep enough information to locate error later. Log relevant data. For example just put `Objects.requireNonNull` for public arguments which must not be null. If they're null, exception will be thrown which should abort current operation. Exception stacktrace will include enough information to pinpoint the bug location and fix it later.
2. Monitor for these messages and act accordingly. My rule of thumb: zero stack traces in logs. Stacktrace is sign of bug and should be handled one way or another.
With bug prevention, it's important to stay reasonable, there's only so much time in the world and business people usually don't want to pay 10x to eliminate 50% bugs. And handling theoretical error conditions also adds to the complexity of codebase and might actually hurt its maintainability.
Re: Look Out for Bugs
#7[flagged]
Re: Look Out for Bugs
#8Does this person also identify performance issues by reading the code? This is completely impractical.
It's a lot easier and better to use profiling in general, but that doesn't mean I never see read code and think "hmm that's going to be slow".
Re: Look Out for Bugs
#9Sounds crazy, but I usually end up doing that, anyway, as I work.
Another tip that has helped me, is to add code documentation to inline code, after it’s written (I generally add some, but not much inline, as I write it. Most of my initial documentation is headerdoc). The process of reading the code, helps cement its functionality into my head, and I also find bugs, just like he mentions.
Re: Look Out for Bugs
#10[flagged]
This can be combined with a more strategic approach like: https://mitchellh.com/writing/contributing-to-complex-projec...