I recently revised the original Factory pattern article, and wanted to write a follow-up after a few years' spent reflecting on its usage within Apex. In particular, I'd like to talk a little bit about the Singleton pattern, and how with a small amount of work we can enhance the existing Factory class in order to gracefully create cached instances of classes where a large amount of work goes into constructing them.| www.jamessimone.net
We owe our ability to understand abstractions in programming to philosophy; much as we owe a debt to mathematics for putting the theorems responsible for our code -- and computers -- to work into words. Consider the immortal words present in the Tao: A well-shut door will stay closed without a latch. Skillful fastening will stay tied without knots. One does not simply (walk into Mordor) build a door that works well. A factory for doors cannot provide you with the quality of worksmanship and p...| www.jamessimone.net
Expressing intent through naming is a challenge, but well-named methods can help to expose even the most complicated of programming mechanisms. In programming, as in life, context is key - let's explore how naming can elevate the intent and rationale behind code! Whether you're just beginning your programming journey or you're a veteran programmer of many years, it's my hope that there's something in this post for everybody.| www.jamessimone.net
The Singleton pattern is frequently used to represent objects that should only be initialized once; either because in being constructed, they feature CPU intensive operations, or because they revolve around atomic operations (like logging a specific time) that should always be referenced consistently. Learn how to improve upon the idiomatic Apex singleton pattern in Salesforce to reap performance benefits and save lines of code at the same time!| www.jamessimone.net
Picklists in Salesforce replace traditional HTML select fields on the front end. They also are driven by complex metadata types that we don't have programmatic access to in our code. I'll discuss one potential approach to strongly typing a picklist's values based on describe results and a little boilerplate.| www.jamessimone.net
API development in Apex is mostly bespoke, requiring the duplication of rest resources. Let's look at how we can change that using inheritance and polymorphism to power our routes. Using extendable, dynamic APIs give us a huge amount of flexibility in spinning up new HTTP routes within the /apexrest/ path, letting us write code that external teams can stress-test and experiment with faster.| www.jamessimone.net