All challenges
Apex ArchitecturePro
Rescuing a Trigger-Logic Monolith
3 decision points1,040 grounded questions
The scenario
An org has three triggers on Account, each with inline SOQL/DML, copy-pasted validation, and intermittent recursion errors. The same 'activate account' rule is duplicated in a trigger, a Visualforce controller, and a batch job. Tests do real DML and are slow and flaky. Refactor to an architecture a team can extend safely.
Constraints to satisfy
- One predictable execution path per object.
- Business rules defined once and reused across trigger, LWC, batch, REST.
- Recursion controlled centrally.
- Logic unit-testable without DML where possible.
Think through your own design first - data model, timing, failure modes. Then walk the decision points and defend each choice against a worked architecture.