Category: Apex

Common Apex Mistakes – Too many SOQL queries

As a Salesforce developer seeing the message “System.LimitException: Too many SOQL queries: 101” can be very frustrating.

In a large codebase it can be time consuming to find and fix these kind of errors. Even when your code is bulkified – why do errors remain?

They may only occur intermittently under certain circumstances, but none the less they still happen.

Continue reading “Common Apex Mistakes – Too many SOQL queries”

Flow for Developers

Rivers, and paddling them in a canoe, can teach you important lessons about going with the flow. You’re never going to successfully paddle upstream against the Yukon (trust me – I’ve been there). Poor communication with a tandem canoe partner can make you both end up swimming. If you get pinned sideways, you must lean in to the obstacle.

The most important lesson, though, is the first one: Go with the flow. Let the river guide you. Work together to get the boat where it needs to be. All that power, blended with a bit of control, can have beautiful results.

Continue reading “Flow for Developers”

From Draft to Finished in Apex

Paul Gardner said “A painting is never finished. It simply stops in interesting places”.

This is 100% true of code. The finish is not the most important thing – when we seek to learn by looking at code, the steps along the way say much more than the end-product alone.

So, as I created a self-contained piece of Apex for a project, I thought that I would git-commit every step. I don’t claim that this code is perfect, but I hope that, by showing my working, it might stimulate thought/discussion. It certainly made me think about the reasons for each step, from draft to finish, more than I otherwise would have.

Continue reading “From Draft to Finished in Apex”

Clean Code – Code versus Comments

As developers we have a responsibility to ensure that any code we write can be easily understood. Especially by any other developer who may come along and take on our code.  Not only that, but writing code in such a way that when we ourselves come back to it, we can still recall what it does and why it does it.

Continue reading “Clean Code – Code versus Comments”

Using Lazy Evaluation to Write Salesforce Apex Code Without For-Loops

Functions or for-loops?

A developer working in Javascript has access to some really convenient functions on Arrays. Functions like filter() and map()  can avoid the need to write for-loops. Is this actually a good thing? Can we write Apex this way?

Continue reading “Using Lazy Evaluation to Write Salesforce Apex Code Without For-Loops”