More Great News From the Salesforce Summer ‘15 Release Notes

Red Argyle logo

While there are lots of great features to look forward to this season, my favorite takeaway from the new Salesforce Summer ’15 Release Notes is the updated code coverage calculation for multiline statements. At first glance this change might seem minor, but, to me, it’s a big deal. I am very picky about the way my code is written and formatted. When code is written with consideration for formatting and readability, it is easier to find bugs and it is easier for other developers to jump in and decipher what is going on. Clean code is very important for developer happiness.

One of my rules for writing clean code is to break up long lines when necessary. Apex is a fairly verbose language, so I often end up with long lines when instantiating a complex object or when chaining multiple functions together. Another common scenario is one in which I’m writing a long SOQL query that selects a long list of fields along with several WHERE clauses. In both of these cases, I find it best to break up the code into multiple lines. Having each SELECT field and WHERE clause on its own line makes the SOQL statement immediately more readable, which means it’s easier to interpret and modify.

Salesforce Summer '15 Release Notes Announce Clean Code Will be Rewarded
Clean Code = Happy Developers

With this new update from the Salesforce Summer ‘15 Release Notes, coverage will be increased by the multiline statements that I write. I could definitely imagine how this could be abused to boost code coverage (see Matt Allen’s post for some other ridiculous coverage cheats), but I take tests seriously. In my case, I think this change will get my code an extra couple percentage points in coverage, which will help the overall coverage of the Org and mitigate the unavoidable poor coverage on the occasional difficult-to-test class. The best way to look at this new feature is that you’ll receive higher test coverage as a reward for writing clean, readable, multiline code!


Red Argyle logo
Red Argyle logo

Related Blog Posts