𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Mastering Apex Programming: A Salesforce developer's guide to learn advanced techniques and programming best practices for building robust and scalable enterprise-grade applications

✍ Scribed by Paul Battisson


Publisher
Packt Publishing
Year
2023
Tongue
English
Leaves
394
Edition
2
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Advance your Apex programming skills to the next level with best practices, proven techniques, and practical code samples with this updated edition along with the most recent advancements in Apex

Key Features

  • Understand the various integration asynchronous processing options in Apex and how to use them to scale you application
  • Learn how to integrate external systems with Apex through both inbound and outbound integrations
  • Profile and improve the performance of your Apex code

Book Description

Applications built on the Salesforce platform are now a key part of many organizations' IT systems, with more complex and integrated solutions being delivered every day. As a Salesforce developer working with Apex, it is important to understand the range and variety of tools at your disposal, how and when to use them, and what the best practices are.

This revised second edition includes a complete restructuring and five new chapters filled with detailed content on the latest Salesforce innovations including integrating with DataWeave in Apex, and utilizing Flow and Apex together to build scalable applications with Administrators.

This Salesforce book starts with a discussion around common mistakes, debugging, exception handling, and testing. The second section focuses on the different asynchronous Apex programming options to help you build more scalable applications, before the third section focuses on integrations, including working with platform events and developing custom Apex REST web services. Finally, the book finishes with a section dedicated to profiling and improving the performance of your Apex including architecture. With code examples used to facilitate discussion throughout, by the end of the book you will be able to develop robust and scalable applications in Apex with confidence.

What you will learn

  • Understand common Apex mistakes and how to avoid them through best practices
  • Learn how to debug Apex code effectively
  • Discover the different asynchronous Apex options, common use cases, and best practices
  • Extend the capabilities of the Salesforce platform with the power of integrations
  • Parse and manipulate data easily with the use of DataWeave functions
  • Develop custom Apex REST services to allow inbound integrations
  • Profile and improve the performance of your Apex code

Who this book is for

Developers who have basic to intermediate Apex programming knowledge and are interested in mastering Apex programming while exploring the Salesforce.com platform. This book is also ideal for experienced Java or C# developers who are moving to Apex programming for developing apps on the Salesforce platform. Basic Apex programming knowledge is assumed.

Table of Contents

  1. Common Apex Mistakes
  2. Debugging Apex
  3. Triggers and Managing Trigger Execution
  4. Exceptions and Exception Handling
  5. Testing Apex Code
  6. Secure Apex Programming
  7. Utilizing Future Methods
  8. Working with Batch Apex
  9. Working with Queueable Apex
  10. Scheduling Apex Jobs
  11. Integrating with Salesforce
  12. Using Platform Events
  13. Apex and Flow
  14. Apex REST and Custom Web Services
  15. Outbound Integrations - REST
  16. Outbound Integrations - SOAP
  17. DataWeave in Apex
  18. Performance and the Salesforce Governor Limits
  19. Performance Profiling
  20. Improving Apex Performance
  21. Performance and Application Architectures

✦ Table of Contents


Cover
Title Page
Copyright and Credits
Contributors
Table of Contents
Preface
Chapter 1: Common Apex Mistakes
Null pointer exceptions
Exceptions on object instances
Exceptions when working with maps
Safe navigation operator
Retrieving configuration data in a bulkified way
Hot and cold data
Bulkification – querying within loops
Bulkification – DML within loops
Hardcoding
Summary
Chapter 2: Debugging Apex
Technical requirements
Debugging on Salesforce
Prevention is better than cure
Log levels
SFDX and streaming logs
Debugging using the Apex Replay Debugger
Apex Interactive Debugger
ISV Customer Debugger
Which tool to use?
Summary
Chapter 3: Triggers and Managing Trigger Execution
The Salesforce order of execution
An example scenario
The save order of execution
Clicks and code
Trigger architecture
Using trigger handler frameworks
Controlling trigger execution
Summary
Chapter 4: Exceptions and Exception Handling
Understanding the different types of exceptions
Expected exceptions
Unexpected exceptions
Unknown exceptions
Catching errors
Using the finally block
Exception logging
Capturing state
Using custom exception types
Summary
Chapter 5: Testing Apex Code
Understanding the importance of testing
Using a test data factory to create data
Loading test data using Test.loadData
The TestSetup annotation
Mocking test data
Testing RESTful web services with static resources
Testing RESTful web services with a custom mock
Testing best practices
Using Test.startTest and Test.stopTest to demarcate the code under test
Using assertions to validate behavior
Writing a test for any bug that occurs
Summary
Chapter 6: Secure Apex Programming
How permissions and sharing work on Salesforce
Sharing and performance
Enforcing sharing
Sharing records using Apex
Enforcing object and field permissions
Understanding Apex class security
Enforcing permissions and security within SOQL
Enforcing user mode for all database operations
Avoiding SOQL injection vulnerabilities
Summary
Chapter 7: Utilizing Future Methods
When to use a future method
Mixed DML
Other use cases for future methods
Defining future methods
Passing state and coordinating data
Calling future methods
Monitoring the execution of future method invocations
Testing future methods
Summary
Chapter 8: Working with Batch Apex
When to use Batch Apex
Large data volumes
Complex logical manipulation processes
High-volume web service callouts
Asynchronous queue processing
Defining a Batch Apex class
The base interface
Invoking Batch Apex
Using Database.executeBatch
Monitoring Batch Apex
Exception handling and platform events
Testing Batch Apex
Summary
Chapter 9: Working with Queueable Apex
What is Queueable Apex?
Queueable versus future
Queueable versus Batch
When to use Queueable Apex
Extensive or complex processes
Callouts
Chained processes
Defining Queueable Apex implementations
Allowing callouts
Invoking Queueable Apex
Enqueuing child/chained jobs
Testing Queueable Apex
Summary
Chapter 10: Scheduling Apex Jobs
When to use Scheduled Apex jobs
One-off executions
Repeating jobs
Defining a schedulable Apex class
Scheduling an Apex class
Using the Apex Scheduler
Using the System.schedule method
System.schedule versus System.scheduleBatch for Batch Apex classes
Suicidal scheduling
Monitoring a scheduled job
Scheduled job limits
Testing scheduled jobs and Apex scheduling
Summary
Chapter 11: Integrating with Salesforce
What is an API?
Types of APIs
Public APIs
Partner APIs
Private APIs
Composite APIs
SOAP versus REST versus gRPC versus GraphQL
SOAP
REST
gRPC
GraphQL
Event/message bus integration
Custom code versus tools
Summary
Chapter 12: Using Platform Events
An overview of the event-driven architecture and the event bus
Exploring event-driven architecture
The event bus
When to use platform events
Defining and publishing a platform event
Using Apex
Publishing platform events through Flow
Using the REST API
Subscribing to and handling platform events
Handling platform events using Apex triggers
Subscribing to platform events in Flow
Change Data Capture and platform events
Testing platform events
Testing whether platform events are publishing
Testing the consumption of platform events
Logging using platform events
A discussion of the CometD protocol and handling events externally
The Pub/Sub API
Integrations using platform events
Summary
Chapter 13: Apex and Flow
Apex and Flow
Invocable actions
Testing invocable actions
Internal APIs
Callouts from invocable methods
External Services in Flow
Summary
Chapter 14: Apex REST and Custom Web Services
An overview of REST
HTTP methods
REST and Apex – when to use custom endpoints
Defining endpoints
A more detailed example
Dynamic parsing using custom metadata
Testing endpoints using Workbench
Exposing endpoints
Public APIs and Sites pages
An alternative using URL Rewriter and Visualforce pages
Handling request body data
Handling JSON
Handling XML
Testing Apex REST code
Summary
Chapter 15: Outbound Integrations – REST
Basic REST callouts
Remote Site Settings
Authentication and named credentials
Using certificates
Testing
OpenAPI and external services
Summary
Chapter 16: Outbound Integrations – SOAP
SOAP overview
WSDL files
Generating Apex
Making asynchronous callouts
Testing callouts
Summary
Chapter 17: DataWeave in Apex
An overview of DataWeave
Script structure
Using DataWeave in Apex
Creating a DataWeave script for use
Calling a DataWeave script from Apex
Testing Apex containing DataWeave
When to use DataWeave
Summary
Chapter 18: Performance and the Salesforce Governor Limits
Understanding the Salesforce application request life cycle
Multi-tenancy and performance
Governor limits and why we should embrace them
Thinking about performance
Summary
Chapter 19: Performance Profiling
Measure twice, cut once
The OODA methodology
Observe
Orient
Decide
Act
Big O notation and magnitude analysis
Profiling Apex performance
Using the Limits class
A utility class to profile Apex
Profiling Visualforce page performance
Profiling LWC performance
Summary
Chapter 20: Improving Apex Performance
Improving CPU time
Faster for loops
Using maps to remove and reduce looping
Reducing the use of expensive operations
Reducing heap size usage
Batched for loops
Using scoping
Removing unwanted items
Improving query selectivity
The number of queries
Retrieving child records with a sub-query
Cache results
Platform Cache
Understanding when to make some of these improvements
Summary
Chapter 21: Performance and Application Architectures
Using clicks with code
Whether to use clicks or code
Clicks, code, and performance implications
Code structure and linting
Object-oriented programming in Apex
Common Salesforce architectural trade-offs
Synchronous versus asynchronous
Wizards to help chunk
Client-side versus server-side processing of data
Enterprise patterns versus flexibility
Managing long-term performance of an application
Summary
Index
Other Books You May Enjoy


πŸ“œ SIMILAR VOLUMES


Mastering Apex Programming: A developer'
✍ Paul Battisson πŸ“‚ Library πŸ“… 2020 πŸ› Packt Publishing 🌐 English

<span><p><b>Get to grips with the advanced features of Apex programming for Salesforce developers using this comprehensive guide</b></p><h4>Key Features</h4><ul><li>Discover how to build reliable applications with Apex by avoiding common mistakes and pitfalls</li><li>Learn how to use the different a

C++ Programming A Complete Guide for Beg
✍ LENA NEIL πŸ“‚ Library πŸ“… 2024 πŸ› Independently Published 🌐 English

C++ programming is a skill that can help you achieve your goals and solve complex problems. With this book, you will learn the basics of C++ and how to design, develop, and implement a robust program from scratch. You will also discover the benefits of using C++ as a general-purpose language, such a