-
Notifications
You must be signed in to change notification settings - Fork 0
Scalability and Performance
The Apex Orbit Framework (AOF) is designed with scalability and performance as primary considerations, especially for Salesforce organizations with a large user base and significant data volumes. Key aspects contributing to this are:
Every layer of the framework, from the AOF_TriggerHandler to Domain, Service, and Selector classes, is designed to operate on collections of records (e.g., List<SObject>, Map<Id, SObject>). This is fundamental to avoiding governor limit exceptions related to DML statements, SOQL queries, and CPU time in a bulk processing context.
- The Selector Layer promotes writing selective SOQL queries by encouraging the use of specific
WHEREclauses and querying only the necessary fields required by the business logic. This reduces database load and improves query performance. - The
AOF_Application_Selectorbase class provides utilities to build field lists dynamically while respecting FLS, ensuring only accessible and queryable fields are included.
- The framework design discourages SOQL queries or DML statements inside loops, a common cause of governor limit issues.
- Efficient use of
Mapcollections is encouraged for accessing related data or comparing old and new record values, which significantly improves processing time for large datasets.
The AOF_Application_UnitOfWork component aggregates all DML operations and executes them in a minimal number of statements (e.g., one insert for all new records of a type). This drastically reduces DML statement consumption, a critical governor limit.
- The Service Layer is the appropriate place to orchestrate asynchronous operations (Batch Apex, Queueable Apex, Future methods) for processes that are too large, too long-running, or might consume excessive resources if run synchronously. This helps in offloading heavy processing and improving responsiveness for users.
- The error handling mechanism, utilizing Platform Events, is inherently asynchronous, ensuring that logging errors does not impact the performance of the primary transaction.
The single trigger per SObject pattern, combined with the AOF_TriggerHandler, provides a streamlined and efficient way to manage trigger execution. It avoids the complexities and potential performance issues of multiple triggers on the same SObject vying for execution order or repeating logic.
The framework encourages the use of Custom Settings or Custom Metadata Types for configurable parameters such as bypass flags, operational thresholds, feature toggles, or endpoint URLs. This allows for administrative control and modification of behavior without code changes, enhancing flexibility and maintainability.
While the framework is designed to operate well within governor limits, the integrated error logging (via AOF_ErrorHandlerService) can capture and log limit exceptions if they occur. This provides valuable diagnostic information for identifying and addressing performance bottlenecks in complex implementations.
AOF avoids unnecessary overhead and complexity, focusing on providing a lean yet powerful set of tools. This contributes to better overall performance as there are fewer layers of abstraction or heavy objects to instantiate and manage for simple operations.
By adhering to these principles, AOF provides a robust foundation that can scale with the evolving needs of a large Salesforce organization, ensuring efficient processing and optimal performance.

Home
Quick Start
Usage Guide and Examples
Metadata‐Driven Trigger
Best Practices
Core Principles
Framework Architecture and Layers
Trigger Handler Layer
Service Layer
Domain Layer
Selector Layer
Unit of Work Layer
Error Handling Framework
Trigger Execution Flow
Scalability and Performance
Security Considerations
Core Components In-Depth
Error Handling In-Depth
Customization and Extension