> ## Content Index
> Fetch the complete content index at: https://www.namastesalesforce.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# 03 · The handler pattern
- URL: https://www.namastesalesforce.com/training/apex-triggers/the-handler-pattern/
- Published: 2025-07-14T09:00:00.000Z
- Updated: 2025-07-14T09:00:00.000Z
- Description: One method per event, a static bypass flag, and constructor-free classes your tests will thank you for.
- Author: Swarnil Singhai
- Tags: Apex Triggers, #training, #duration-15m, #Import 2026-09-03 19:13

One method per event, a static bypass flag, and constructor-free classes your tests will thank you for.

## The shape

beforeInsert(newList), afterUpdate(oldMap, newMap) — the trigger passes context variables straight through. The handler owns every decision; the trigger owns nothing.

## The bypass flag

A public static Boolean lets data migrations and tests switch the handler off without touching metadata. Use sparingly; log every use.

## Practice in your org

- Open your Developer Edition org and follow along step by step
- Change one thing at a time and note what happens
- When something breaks, read the error before searching for it