Category: Development

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”

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”

Debugging For Salesforce Developers

A bug has been reported in production and there’s no obvious path to the problem. What are you going to do? A build process is failing and the errors make no sense. What are you going to do? A report is showing you things in the data that just shouldn’t happen. What are you going to do?

Continue reading “Debugging For Salesforce Developers”

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”

Performance Testing of Process Builder vs Apex

The choice between writing custom Apex code or using declarative tools in Salesforce has always been a difficult one to make. Process Builder is capable of more than Workflow was, but it came at a big performance cost. In this article, Roger Mitchell measures that performance cost again. And it looks like things have improved considerably since 2016. Continue reading “Performance Testing of Process Builder vs Apex”