Best Practices
Best Practices
Working effectively with the Breezz Framework requires following a few key principles. These best practices will ensure your scheduled jobs are performant, scalable, and easy to maintain.
1. Choose the Right Job Type (Standard vs. Batch)
The most common architectural decision is choosing between standard and batch job types.
- Standard Jobs: Use these for high-frequency execution (e.g., every few hours) on small datasets (up to a few hundred records).
- Batch Jobs: Always choose the
- Batchvariant (e.g., Steps Group - Batch, Cleanup - Batch) when dealing with data volumes exceeding standard Salesforce limits, typically anything over a few thousand records (e.g., 10,000+).
2. Optimize Your SOQL Queries
The SOQL Query field in the Scheduler Job configuration is your first line of defense against hitting governor limits.
- Always filter out records that don’t need processing (e.g.,
WHERE Status != 'Closed'). - Only select the fields you actually need to read or modify in your context.
3. Writing Custom Step Classes
When writing custom Apex logic (like Custom Jobs or Step Groups), adhere to the framework’s structure:
- Required Constructors: You must include a public default constructor that calls
super(YourClassName.class.getName());. Without this, the framework cannot execute the step in an async context or generate proper error logs. - Use the Modification Context: Avoid writing direct DML statements (
insert,update,delete). Instead, usegetContext().addModificationToUpdate(...)to stage changes safely.
4. Robust Test Coverage
Breezz provides built-in testing utilities. Always utilize them:
- Initialize the framework in your
@TestSetupusingforvendi.BreezzApi.TESTS.init('BreezzPlugin');. - Execute your steps using
forvendi.BreezzApi.STEPS.build().addStep(...).execute(...);. - Assert Error Logs: Always call
forvendi.BreezzAPI.TESTS.assertErrorLogs();at the end of your tests to ensure no hidden framework errors occurred during execution.****