Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Mastering Apex Programming
Why subscribe?
Foreword
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Section 1 – Triggers, Testing, and Security
Chapter 1: Common Apex Mistakes
Technical Requirements
Null pointer exceptions
Exceptions on object instances
Exceptions when working with maps
Retrieving configuration data in a bulkified way
Bulkification – querying within loops
Hardcoding
Summary
Chapter 2: Debugging Apex
Technical requirements
Debugging on Salesforce
Prevention is better than a 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
Technical Requirements
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
Technical Requirements
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
Technical Requirements
Understanding the importance of testing
Using a test data factory to create data
Loading test data using Test.loadData
Testing RESTful web services with static resources
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
Avoiding SOQL injection vulnerabilities
Summary
Section 2 – Asynchronous Apex and Apex REST
Chapter 7: Utilizing Future Methods
Technical Requirements
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 execution of future method invocations
Testing future methods
Summary
Chapter 8: Working with Batch Apex
Technical Requirements
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
Technical Requirements
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: Using Platform Events
Technical Requirements
An overview of 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
Using Process Builder to publish events
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 Process Builder
Change Data Capture and platform events
Testing platform events
Testing whether platform events are publishing
Testing the consumption of platform events
A discussion of the CometD protocol and handling events externally
Summary
Chapter 12: Apex REST and Custom Web Services
Technical requirements
An overview of REST
HTTP methods
REST and Apex – when to use custom endpoints
Custom logic or complex 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
Section 3 – Apex Performance
Chapter 13: Performance and the Salesforce Governor Limits
The Salesforce application request lifecycle
Multi-tenancy and performance
Governor limits and why we should embrace them
Thinking about performance
Summary
Chapter 14: Performance Profiling
Technical Requirements
Measure twice, cut once
The OODA methodology
Observe
Decide
Act
Profiling Apex performance
A utility class to profile Apex
Profiling Lightning Web Components performance
Summary
Chapter 15: Improving Apex Performance
Technical Requirements
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
Number of queries
Retrieving child records with a sub query
Cache results
Platform Cache
Understanding when to make some of these improvements
Summary
Chapter 16: 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 versus server processing of data
Enterprise patterns versus flexibility
Managing long-term performance of an application
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
← Prev
Back
Next →
← Prev
Back
Next →