On Not Writing Bad Exception Handlers

Unlike some languages (such as Python) where exceptions have a greater role in flow control, in Apex, exceptions generally are exceptional: they connote some relatively uncommon bad state in the application that prevents the normal path of execution from continuing without some special handling. An exception is a message from the application to you, and one that you ignore at your, and your users’, peril!

More …

Nested Iteration: A Quick Look at Computational Complexity in Apex

The logic of nested iteration can be a real trap for new programmers. I see this a lot on Salesforce Stack Exchange, coming from two different angles. One angle simply asserts, having been taught so, that “nested loops are bad.” Well, not exactly - not as such, although they can be in specific implementations. The other side perceives no danger at all in nested loops - indeed, finds them the most natural, if naive, route to expressing certain search constructs.

More …

Real-World Unit Testing: Get to 100% Coverage, the Right Way

My presentation from PhillyForce ‘19, “Real-World Unit Testing: Get to 100% Coverage, the Right Way”, is now available on YouTube. It was a great experience to return to PhillyForce as a speaker and organizing committee member to talk about one of the subjects I’m most passionate about - automated testing - and make the case that writing good unit tests is actually a moral, not just a technical, imperative.

More …

Three Routes to Time-Based Rollup Summary Fields

Rollup Summary Fields are great. Users love them because they offer at-a-glance insight at the top level of the data hierarchy, without needing to run a report or drill down in the user interface to child records. Unfortunately, native Rollup Summary Fields come with a variety of limitations on what data you can roll up, where, and applying which criteria. In particular, time-based rollup summary fields are a common need that’s tricky to meet with this native functionality.

More …