Release Notes - mouttaqui/AOF GitHub Wiki

Version 1.0.0 - May 18, 2025

Overview

The Apex Orbit Framework (AOF) is a lightweight, scalable, and easy-to-use Salesforce Apex framework designed to streamline development and enforce best practices. This initial release provides a complete implementation of a trigger framework with separation of concerns, robust error handling, and security enforcement.

Key Features

  • Layered Architecture: Clear separation between Trigger Handler, Domain, Selector, Service, and Unit of Work layers
  • Single Trigger Per Object: Simplified trigger management with predictable execution order
  • Bulkification: All components designed to handle collections of records efficiently
  • Security Enforcement: CRUD permission checks at commit time in the Unit of Work
  • Error Handling: Asynchronous logging via Platform Events and custom objects
  • Bypass Mechanism: Static methods to bypass triggers when needed
  • Comprehensive Documentation: Detailed guides, examples, and architecture diagrams

Components

Core Framework Classes

  • AOF_TriggerHandler.cls - Base trigger handler for orchestrating trigger execution
  • AOF_Application_Domain.cls - Base domain class for SObject-specific business logic
  • AOF_Application_Selector.cls - Base selector class for querying data with security enforcement
  • AOF_Application_Service.cls - Interface for service layer components
  • AOF_Application_UnitOfWork.cls - Unit of Work implementation for transaction management
  • AOF_ErrorHandlerService.cls - Error logging service using Platform Events
  • AOF_SecurityException.cls - Custom exception for security violations

Example Implementation

  • AOF_AccountDomain.cls - Example domain implementation for Account object
  • AOF_AccountSelector.cls - Example selector implementation for Account object
  • AccountTrigger.trigger - Example trigger implementation using the framework

Test Classes

  • AOF_Application_Domain_Test.cls - Tests for the domain layer
  • AOF_Application_Selector_Test.cls - Tests for the selector layer
  • AOF_Application_UnitOfWork_Test.cls - Tests for the Unit of Work
  • AOF_ErrorHandlerService_Test.cls - Tests for the error handling service

Technical Specifications

  • Naming Convention: All framework components use the AOF_ prefix to prevent naming conflicts
  • Code Quality: Follows Apex PMD best practices with no empty block statements or System.debug calls
  • Test Coverage: Comprehensive test classes with System.runAs() for proper user context testing
  • Error Handling: Platform Events for asynchronous error logging to prevent transaction failures
  • Security: Object-level CRUD checks performed at commit time in the Unit of Work
  • Scalability: Designed for orgs with 10,000+ users with focus on governor limit optimization

Implementation Requirements

Custom Metadata/Objects Required

  • Platform Event: ErrorLogEvent__e with fields:

    • Timestamp__c (DateTime)
    • OriginatingClassName__c (Text)
    • OriginatingMethodName__c (Text)
    • LineNumber__c (Number)
    • ErrorMessage__c (Long Text Area)
    • StackTrace__c (Long Text Area)
    • SObjectType__c (Text)
    • RecordIds__c (Text)
    • Severity__c (Picklist)
  • Custom Object: Error_Log__c with corresponding fields to store error data

Installation Steps

  1. Create the required Platform Event and Custom Object
  2. Deploy all Apex classes with the AOF_ prefix
  3. Create a trigger on ErrorLogEvent__e to persist records to Error_Log__c
  4. Implement SObject-specific domain and selector classes as needed
  5. Create single triggers for each SObject that call the framework

Best Practices

  • Create one trigger per SObject that delegates to the framework
  • Implement business logic in domain classes, not directly in triggers
  • Use selectors for all database queries to ensure security and optimization
  • Register DML operations with the Unit of Work rather than performing direct DML
  • Implement proper error handling using the provided error service

Known Limitations

  • Custom metadata-driven configuration not included in this version
  • Field-level security (FLS) enforcement in selectors relies on WITH SECURITY_ENFORCED
  • Error logging requires proper setup of Platform Events and a subscriber trigger

Future Enhancements

  • Custom metadata-driven trigger configuration
  • Enhanced field-level security enforcement options
  • Additional utility methods for common operations
  • Integration with Salesforce Platform Cache for optimization
  • Support for custom permission-based feature toggles

© 2025 Apex Orbit Framework. All rights reserved.