fallbackcg

Learning and Mastering Salesforce Apex

Last year our COO Paul wrote and published two books on the Salesforce Apex programming language – “Learning Salesforce Development with Apex” and “Mastering Apex Programming“. Both have received great reviews on Amazon and we asked Paul to give us a bit of background as to why he wrote the books, who might be interested in reading them, and how to best learn and master the Apex language.

 

Where the idea came from

Over the 12 years I have been working with Salesforce, I have worn a number of hats. I have been a product manager, a developer, an architect, and a trainer to name but a few. I have been lucky enough to get to help a number of people start off working on the platform. A couple of years ago I took this to the next level and became a Salesforce Certified Instructor. I have noticed there are a number of key areas which many people find tough when working with Apex. I have found this both in helping people get up to speed on the platform, and as a senior team member on projects mentoring and guiding others.

Learning any programming language is difficult, but I think Apex is uniquely tough sometimes. For starters, it is not typically taught at university. You have a few hurdles to getting setup such as getting a developer environment and knowing how to navigate Salesforce. There is often a lack of abstract learning and reference material. We are blessed with many learning resources in the Salesforce ecosystem. There are official options like Trailhead and the Trailhead Academy classes and additional material from community members including blogs and courses. I personally find I learn best from a book. I like the ideas and concepts explained to me with an example. But I also want it in a way I can come back to and use in the abstract later.

 

Learning Salesforce Apex

I agreed to write my first book, “Learning Salesforce Development with Apex” to help try and plug this gap for those new to Salesforce Apex. For admins and junior developers there can be a plethora of terms and concepts that are difficult to grasp. It can also be difficult to learn a programming language. Many of the pieces need you to know other pieces first. Many learners struggle as too many concepts are taught at once. This makes it difficult to understand the topic at hand.

Learning Salesforce Development With Apex Book Cover

In writing this book, I tried to make it simple and easy for someone to go through, chapter by chapter, and focus on one topic at a time. I cover a lot of the concepts in the abstract first, irrespective of the programming language. Whether it is Salesforce Apex or some other language, many of the core concepts are the same. So understanding them in general will make it much easier to apply them when needed. I also tried to make it easy to both jump to a section in the book, so it can be used as a reference. If you are a new developer or Salesforce Admin trying to learn Apex, hopefully it will help your understanding.

 

Junior to Advanced Developer – Mastering Salesforce Apex

As I was writing the first book it became clear that there were many areas I wanted to cover or cover in more detail, but were not really right for a beginners book. I therefore began noting down a list of areas that would help someone who had been working with Salesforce Apex for a few years really begin to master the language. At this point I want to thank Mike Gill, one of our awesome architects. Not only did Mike help sense check the ideas but was a brilliant technical reviewer throughout.

Mastering Apex Programming

The focus of “Mastering Apex Programming” is therefore on understanding some of the more complex areas of Salesforce Apex. I was fortunate when I started that it was easy to be on the bleeding edge of Apex. This was because the platform was a lot smaller and everything was bleeding edge. In my time working with Salesforce and Apex, a number of huge innovations have occurred to the language. Batch Apex, Platform Events, updates to the testing framework, Queueable Apex and Apex REST to name a few. These options all help you to deliver more robust and scalable applications, but are not used by every developer. They can be very min-boggling when you first start working with them.

The book falls into 3 sections. Firstly it discusses common mistakes and best practices. I felt this was an important first section to help ensure that the common silly mistakes we all make are identified and dealt with. The second section focusses on the various asynchronous Apex options and how and when to use them. The third and final section focusses on performance. This has long been an area of interest for me and I recently spoke on this at London’s Calling.

 

The Trilogy?

A few people have asked if I have a third book in mind to complete a trilogy. Currently this is a no, but never say never. Being locked indoors for a year due to the pandemic allowed me to focus on getting these books written, something that I am sure would have been harder in a normal year. I would also encourage anybody who is interested in writing a book to do it. There can never be too much material on a subject in my opinion. I categorically do not see my books replacing any of the amazing existing works out there. Rather it is a different set of eyes and experiences on the subject.

Phil's Salesforce Tip of the Week

Which Automation Tool Do I Use? – Phil’s Salesforce Tip of the Week #413

This week I stumbled across this great page that gives some fantastic details on when you should use each of the different automation tools Salesforce provides. I really like this page because it provides a great quick reference for people to look at when trying to determine the best tool to work with. When I first started it was pretty easy to decide as workflows were the only option. With the variety of tools now available to use on the platform, it’s a lot harder, particularly for those starting out to know what tool to use when. Hopefully this page can help in answering those questions.

Which Automation Tool to Use

Other top tips and news…

Hierarchical Relationship on Users

I was working with one of the team on a project this week where we needed to have a relationship between users, a perfect use case for the Hierarchical Relationship Type! Its only available on the User object, but I wanted to make sure I shared it as a top tip as not a lot of people had come across it.

New Book – Learning Salesforce Development With Apex

Our very own COO Paul Battisson has just released his first book – Learning Salesforce Development with Apex, designed to help those with little or no programming experience understand the Apex programming language. Congratulations Paul on this great achievement, if you want to buy a copy, you can grab one from Amazon here.

fallbackcg

Salesforce Evergreen – A Game Changer For Salesforce Developers

Last week was Salesforce’s annual #Dreamforce conference in San Francisco. It’s when over 100,000 Salesforce fans descend upon the city to listen to the latest innovations from Salesforce. I was unable to attend this year, but followed along closely at home to the announcements. The one that stood out to me in particular was not Salesforce Blockchain, Einstein Voice or Customer 360 – it was the Salesforce Evergreen announcement that for me could be the real game changer.

 

The Impact of Serverless

To understand why you have to perhaps take a step back and look at how the rise of AWS and in particular, the AWS Lambda and the serverless paradigm has impacted development.

Take the following example – you want to upload an image in Salesforce against a case both before and after work is completed. These images should be stored off platform in Amazon S3 and you want to have both the original and a thumbnail, with the thumbnail being displayed on the case. Whilst uploading the images to S3 could be done via Apex in Salesforce, the resizing must be done off platform currently. So how do we do this and where?

We can either have an endpoint available on a platform like Heroku with a dyno running, or have a Lambda function that will run whenever called. That’s the key difference here, we have to have the Heroku dyno (at least 1) running to handle requests whereas with Lambda we are only paying per executed function. (Note this example is based upon a Lambda example from AWS you can read about here.) Whilst I am a big fan of Heroku, use cases like this lend themselves more to Lambda for running small jobs and repetitive functions where there is no need for a full web server framework to be setup, just receiving and processing some data from an event.

Such scenarios are becoming more common as organisations want to connect more pieces of their process seamlessly. This has driven a number of people towards using serverless based solutions to handle these simple problems – they just need the code to run and perform the action. Many organisations are also working to modularise their systems into more discrete functional blocks, often referred to as microservices. I’ve written before on Salesforce and Microservices and spoken on the topic previously at Dreamforce 2015 and Dreamforce 2017.

Previously, the conversation has always been how to make Salesforce interact nicely with serverless systems, or how to rearchitect parts of your existing Salesforce setup to operate in a more modular way. As soon as some more complicated processing was required (such as image resizing) you were forced off platform and had to decide which platform to use. How would you manage security and authentication? How could you invoke the new service – API via code or a Platform Event? You couldn’t think of doing all this on Salesforce – until now.

Enter Evergreen

Salesforce Evergreen is a new toolkit that will allow developers to write small functions and microservices using Apex, Java and Node.js which can be invoked natively from within Salesforce using both declarative and code based tools, as well as having native visibility to the platform – so no need to manage authentication.

Salesforce Evergreen Architecture

Taking our previous example, instead of a service running off platform, whether Heroku or AWS, we could now have a small set of functions that are called directly from the declarative tools in Salesforce. Whenever a case is closed. upload the images from Salesforce to S3, process these images and update the case. No additional infrastructure needed, no authentication required, all on a single platform.

This is truly game changing, by allowing developers to build these functions using existing languages in Java and Node.js, you are enabling the developer to utilise all of the existing ecosystem of functionality out there. For example, npm, the package ecosystem for Node.js, has somewhere in the region of a million packages, covering all types of functionality – csv parsing to providing random jokes. Almost all of these libraries become available for use alongside your existing Salesforce applications with all the plumbing and authentication done for you! You simply add in what you need, leveraging the existing tools and off you go.

Similarly, if you have an existing complex function in Java from an existing application, you can migrate that to become an Evergreen function and deploy it for use from within Salesforce! As wonderful a language as Apex is there are some things that it cannot do or that Java or Node.js will be a better tool for, now you can leverage these languages to do more with your Salesforce data.

Summary

The new Evergreen toolkit is going to make a huge difference to what is possible for Salesforce developers and opens up exciting new possibilities which should lead to some incredible new solutions. I am already signed up for updates from Salesforce on the Developer Preview and will be looking ahead for different applications for this toolkit for our customers. If you want to read more, Salesforce have posted a blog here.