Suggested answer

Apex Enterprise Patterns (from the fflib open-source framework) provide a structured, scalable architecture:

1. Selector Layer: Centralises all SOQL queries for an object. Each selector class queries the object and enforces consistent field sets and FLS. Prevents repeated, inconsistent queries across the codebase.
2. Domain Layer: Encapsulates business logic for a specific object (the "domain"). Trigger handlers call the domain class, which contains methods like onBeforeInsert().
3. Service Layer: Coordinates cross-object business logic and orchestrates calls between domain and selector layers. Called from triggers, LWC, REST endpoints.
4. Application Factory: A factory class (using the Selector/Domain/Service interfaces) that allows dependency injection and mocking in tests. This pattern makes large codebases maintainable, testable, and consistent.

Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.

Community comments (0)

No comments yet.

Sign in or create a free account to add a comment. Comments are moderated before they appear.

Plain text only, 3–2000 characters. A moderator reviews every comment before it is published.