Let's say we are publishing platform events on Salesforce event bus. Some of the trigger points will provide an input of a List of records, some of the trigger points will only provide one record. Does it ever make sense to create a somewhat "duplicate" logic, but two routes, one for the processing of a single record, second for a processing of multiple records? For example:
public without sharing class ProcessingHandler {
public static void processRecord(Case oneCase){
// simplified logic
}
public static void processRecords(List<Case> moreCases){
// bulkified logic
}
}
The advantages:
- Possibility to process a single record a little bit faster because a not bulkified route should execute a little bit faster (Maximum CPU time on the Salesforce servers).
The disadvantages:
- Extra verbosity (Maximum number of characters for a class, Maximum amount of code used by all Apex code in an org).
I wanted to ask if my reasoning is correct and generally what is the standard on Salesforce platform?