Skip to main content

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.

Salesforce · Salesforce

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.

3 min read
Salesforce · Salesforce

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.

3 min read
Salesforce · Salesforce

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.

3 min read
Salesforce · Salesforce

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.

4 min read
Salesforce · Salesforce

Flow Migration from Apex: The Pragmatic Path

Migrating Apex triggers to Flow. When to migrate, when not to, how to do it safely.

3 min read
Salesforce · Salesforce

GitHub Copilot for Salesforce Apex

Copilot in VS Code for Apex and LWC development. What it does well, patterns to adopt, what it misses.

2 min read
Salesforce · Salesforce

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.

4 min read
Salesforce · Salesforce

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.

4 min read
Salesforce · Salesforce

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.

4 min read
Salesforce · Salesforce

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.

4 min read
Salesforce · Salesforce

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.

5 min read
Salesforce · Salesforce

Apex Modernization in 2026

Patterns to modernize legacy Apex — async everywhere, structured errors, testability, observability.

2 min read
Salesforce · Salesforce

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.

2 min read
Salesforce · Salesforce

Apex Test Class Best Practices for 2026

Modern Apex test class patterns — test data factories, mocking, assertions, and what actually counts as 'good' coverage.

5 min read

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.

Related topics