Book Image

Mastering Apex Programming

By : Paul Battisson
5 (1)
Book Image

Mastering Apex Programming

5 (1)
By: Paul Battisson

Overview of this book

As applications built on the Salesforce platform are now a key part of many organizations, developers are shifting focus to Apex, Salesforce’s proprietary programming language. As a Salesforce developer, it is important to understand the range of tools at your disposal, how and when to use them, and best practices for working with Apex. Mastering Apex Programming will help you explore the advanced features of Apex programming and guide you in delivering robust solutions that scale. This book starts by taking you through common Apex mistakes, debugging, exception handling, and testing. You'll then discover different asynchronous Apex programming options and develop custom Apex REST web services. The book shows you how to define and utilize Batch Apex, Queueable Apex, and Scheduled Apex using common scenarios before teaching you how to define, publish, and consume platform events and RESTful endpoints with Apex. Finally, you'll learn how to profile and improve the performance of your Apex application, including architecture trade-offs. With code examples used to facilitate discussion throughout, by the end of the book, you'll have developed the skills needed to build robust and scalable applications in Apex.
Table of Contents (21 chapters)
1
Section 1 – Triggers, Testing, and Security
8
Section 2 – Asynchronous Apex and Apex REST
15
Section 3 – Apex Performance

What this book covers

Chapter 1, Common Apex Mistakes, starts the book by reviewing some common mistakes developers make when working with Apex and addresses the root cause of the infamous Attempt to de-reference a null object error and what it actually means.

Chapter 2, Debugging Apex, covers the different ways in which you can debug your Apex to understand what is actually happening in an error. Correctly developing this skill can save hours of lost time when working through an issue.

Chapter 3, Triggers and Managing Trigger Execution, details the save order of execution for triggers in detail and how we, as developers, need to architect our triggers to handle bulkified data in a consistent manner.

Chapter 4, Exceptions and Exception Handling, is focused on the correct handling and management of exceptions within our code, an often overlooked aspect of development.

Chapter 5, Testing Apex Code, provides a detailed discussion of Apex testing, its key role in helping prevent and debug errors, and how to improve your experience in developing tests to make it quicker and easier.

Chapter 6, Secure Apex Programming, reviews the different ways of avoiding security flaws within our code to avoid vulnerabilities.

Chapter 7, Utilizing Future Methods, covers use cases, as well as how to use and test future methods within our application.

Chapter 8, Working with Batch Apex, details use cases, the structure of, and monitoring of Batch Apex to work with large volumes of data asynchronously.

Chapter 9, Working with Queueable Apex, builds on the previous chapter to discuss the differences between Batch and Queueable Apex, the appropriate use cases for each, and how to work with Queueable Apex successfully.

Chapter 10, Scheduling Apex Jobs, discusses the use of Scheduled Apex within a system and the different ways in which we can schedule Apex for specific use cases.

Chapter 11, Using Platform Events, describes the platform event feature, the use of an event bus and event-driven architecture, as well as the different ways to publish and subscribe to platform events to help build decoupled and scalable applications.

Chapter 12, Apex REST and Custom Web Services, provides a discussion of what the Apex REST framework is and how we can utilize it to build custom REST endpoints to allow integrations from external systems.

Chapter 13, Performance and the Salesforce Governor Limits, covers the Salesforce governor limits at a high level and how we should think about performance management in regard to Salesforce and Apex.

Chapter 14, Performance Profiling, details how to profile the performance of applications on Salesforce and correctly analyze the results.

Chapter 15, Improving Apex Performance, goes through specific examples of how to improve the performance of your Apex code.

Chapter 16, Performance and Application Architectures, finishes the book with a discussion on the impact different architectures can have upon application performance.