The job Write it as Watch for
Logic that runs on every save of a record A trigger that calls a handler class Flows and triggers on the same object both firing. Decide which one owns each field.
A nightly cleanup or recalculation across thousands of records Batch Apex: a class implementing Database.Batchable<sObject> with start, execute and finish Each chunk is its own transaction. One failed chunk doesn't roll back the others.
Work that should happen after the save, like calling another system A Queueable class, started with System.enqueueJob Callouts from a trigger must be asynchronous. Salesforce blocks them in the save itself.
A step an admin wants inside a Flow A static method marked @InvocableMethod It receives a list, because Flow sends records in bulk.
Another system needs to push data into Salesforce A class annotated @RestResource with @HttpPost methods Check whether the standard REST API already does it before writing your own endpoint.