Mastering Apex Programming A Salesforce Developer's Guide to Learn Advanced Techniques and Programming Best Practices for Building Robust and Scalable Enterprise-Grade Applications
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, h...
Other Authors: | |
---|---|
Format: | eBook |
Language: | Inglés |
Published: |
Birmingham, England :
Packt Publishing Ltd
[2023]
|
Edition: | Second edition |
Subjects: | |
See on Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009785406106719 |
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.