ISSUE #69 - August 12, 2018
Testing is a valuable activity that reveals bugs, so that they can be fixed. Wouldn’t it be better, though, if the bugs weren’t there in the first place? There are some techniques to avoid coding the bugs in. Tell your dev friends!
Learn about “The Last Line Effect”: when copy/pasting blocks of code and making a change in each, it is the last block that will frequently contain a bug. Worth keeping in mind when acting as a peer code reviewer.
Google researchers look at the bugs in selecting arguments to a method call (in Java), conclude that probability of bugs increases markedly when methods have >5 arguments. They hence advise to keep the argument list at 5 or shorter, and to not reorder parameters in methods that are similar in meaning, or related through inheritance.
Rollbar analyzed most common errors in web projects tracked by their service, and published a series of data-driven blog posts detailing those common bugs per language, with tips on preventing them! This is a pretty awesome resource.
Ruby on Rails:
For other languages (Python, C#, Java), see the Toptal posts referenced in our older TD issue:
Not so immediately applicable (no open source tool available) but conceptually interesting: bugs tend to cluster around “architectural hotspots” which are specific files in the source code and/or inheritance hierarchies, dependency cycles, or unstable interfaces. If you can locate these hotspots in your codebase, any changes in those risky areas would deserve a more careful review.
Even deeper into the weeds, consider the “naturalness” of buggy code: Just like true natural language, programming languages can be modeled using machine learning techniques (such as n-gram modeling) that will predict which sequences are “normal” vs “unusual”. The unusual ones are likely to be buggy. With this tooling one could detect statistically improbable and yet syntactically correct lines of code and warn the developer of possible bugs. I only wish this was an open source project, not just a research paper…
Story of a bug: video calls mysteriously drop after 1100 seconds… learn what ‘nonce’ means:
If you received this email directly then you’re already signed up, thanks! Else if this newsletter issue was forwarded to you and you’d like to get one weekly, then you can subscribe at http://testersdigest.mehras.net
If you come across content worth sharing, please send me a link at firstname.lastname@example.org