How should I structure a complex Batch job with multiple actions?
Simplify a complex #Batch job by breaking it into smaller, modular components — using either approach individually, or both together:
- Multiple Executables in a Pipeline — Divide the logic across multiple Executables, each handling a specific action, and group them within a Pipeline.
- Defer Logic to #Triggers — Keep the #Batch focused on retrieving records and performing DML, and let DSP #Triggers (or other automations) handle the downstream logic that fires from those DML events. This shifts complexity out of the batch itself and into reusable, event-driven units.
Breaking complex logic into modular pieces keeps each step focused and testable, isolates failures so they don't cascade, and makes the system far easier to evolve as needs change.