
Mastering Apex Programming
Beschreibung
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.
Alle Preise
Weitere Details
Weitere Ausgaben
Inhalt
- 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
Systemvoraussetzungen
Dateiformat: ePUB
Kopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
- Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).
- Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions oder die App PocketBook (siehe E-Book Hilfe).
- E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an.
Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.
Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.
Dateiformat: ePUB
Kopierschutz: ohne DRM (Digital Rights Management)
Systemvoraussetzungen:
- Computer (Windows; MacOS X; Linux): Verwenden Sie eine Lese-Software, die das Dateiformat ePUB verarbeiten kann: z.B. Adobe Digital Editions oder FBReader – beide kostenlos (siehe E-Book Hilfe).
- Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions oder die App PocketBook (siehe E-Book Hilfe).
- E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m.
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „glatten” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an.
Ein Kopierschutz bzw. Digital Rights Management wird bei diesem E-Book nicht eingesetzt.
Weitere Informationen finden Sie in unserer E-Book Hilfe.