Bulkification: The First Rule of Apex Club

Photo by Andy Li on Unsplash

By now, I don’t just write Apex that works—I write Apex that scales. That means one thing above all: bulkification.

Salesforce doesn’t like it when you loop through records and perform DML (like insert, update, etc.) inside the loop. So I always structure code to:

  • Collect data in a List<> or Map<>

  • Perform logic in bulk outside the loop

  • Use Set<Id>s to query efficiently

Every time I write a trigger or utility class, I ask: Can this handle 200 records at once? If not, it’s not ready.

Bulk-safe code = deployment-safe code.