Topic hub
Salesforce Apex — practical guides
Apex is Salesforce's strongly-typed, server-side language. Use it when declarative tools (Flow, Validation Rules, Formulas) hit a ceiling. Below: trigger handler patterns, governor-limit safety, async Apex, REST endpoints, and tested templates you can copy.
The Apex == Trap That Breaks Map and Set Lookups
Apex's equality operator does field-by-field comparison on SObjects — except when it doesn't. The four cases that produce wrong Map and Set hits.
The 1,500-Char Formula Limit Is a Design Signal
Hitting the cross-object formula character cap isn't a bug to work around — it's the platform telling you to restructure. Here's how.
Queueable Finalizers: The Idempotent Async Apex Pattern
Queueable finalizers are the cleanest async error-recovery pattern in Apex. Here is the production-ready template with idempotency baked in.
Record-Triggered Flow Recursion in 2026: Guards That Hold
Flow recursion patterns for 2026. Static guards, change-tracking, and the static variable trick that survives Apex co-execution.
Flow Migration from Apex: The Pragmatic Path
Migrating Apex triggers to Flow. When to migrate, when not to, how to do it safely.
GitHub Copilot for Salesforce Apex
Copilot in VS Code for Apex and LWC development. What it does well, patterns to adopt, what it misses.
Salesforce Governor Limits Cheat Sheet (2026 Edition)
The governor limits that matter in 2026 — per-transaction, per-24-hour, and how to design around each one in Apex and Flow.
Apex Triggers Bulkification: The Complete Checklist
The full bulkification checklist for Apex triggers — what the patterns are, how to verify them, and how to catch violations early.
Wire vs Imperative Apex in LWC: When to Use Each
A clear decision guide for @wire vs imperative Apex calls in Lightning Web Components — with caching, error handling, and refresh patterns.
Agentforce Actions: Design Patterns That Don't Break
Principles and concrete patterns for designing Agentforce actions that the agent calls correctly and that don't fail in production.
Apex Async Options Decoded: Queueable, Batch, Future, Scheduled
When to use each Apex async option — Queueable, Batch, @future, Scheduled — with concrete use cases and decision rules.
Apex Modernization in 2026
Patterns to modernize legacy Apex — async everywhere, structured errors, testability, observability.
Apex AI Assist: The 2026 Developer Patterns
Vibes 2.0, GitHub Copilot for Apex, Cursor — AI-assisted Apex development in 2026. What's mature, what isn't.
Apex Test Class Best Practices for 2026
Modern Apex test class patterns — test data factories, mocking, assertions, and what actually counts as 'good' coverage.
Frequently asked
When should I write Apex instead of Flow?
Reach for Apex when you need bulk-safe iteration over more than a few thousand records, complex transactional integrity, callouts beyond Flow HTTP capabilities, or precise governor-limit control. For straightforward record updates, notifications, and approvals, Flow is faster to build and easier to maintain.
What is the trigger handler pattern?
A trigger handler pattern moves business logic out of the trigger body into a dedicated handler class. The trigger is a thin dispatcher — it routes events (before insert, after update, etc.) to handler methods. This pattern enables unit testing, prevents recursion, and lets multiple developers extend logic without merge conflicts.
How do governor limits affect Apex?
Each transaction has hard caps: 100 SOQL queries, 150 DML statements, 6 MB heap (12 MB async), 10 s synchronous CPU. Hitting any limit throws an unhandled exception. Always SOQL outside loops, use collections for DML, and use Limits class methods to log usage in production.