The 24th Design Pattern: The Barzakh Pattern

### The 24th Design Pattern: The Barzakh Pattern The Gang of Four gave us 23 design patterns. They solved problems like object creation, composition, and interaction. But they were writing in 1994. Before cloud infrastructure. Before microservices. Before distributed systems became the default. And, perhaps most importantly, before every production engineer discovered what a 02:37 AM PagerDuty notification feels like. So I have a proposal for the unofficial **24th Design Pattern**: # The Barzakh Pattern Not an official addition to the GoF catalog. But perhaps a pattern we need for modern distributed systems. ### The Problem Modern systems don't only deal with business requests. They deal with everything the outside world can throw at them: - unexpected traffic - malformed messages - retries - duplicated events - abusive clients - noisy integrations - delayed dependencies - traffic arriving at the worst possible moment The dangerous assumption is: > **If an event reaches our system, our Core System should deal with it.** Why? The Core shouldn't have to know about every piece of chaos happening outside its boundary. ### The Pattern **The Barzakh Pattern introduces a deliberate boundary between the External World and the Core System.** The boundary has one fundamental responsibility: > **An external event does not automatically earn the right to enter the Core.** Conceptually: ```text EXTERNAL WORLD │ ▼ ┌─────────────────┐ │ BARZAKH │ │ │ │ Admission │ │ Isolation │ │ Classification │ │ Deferral │ └────────┬────────┘ │ admitted work │ ▼ ┌─────────────────┐ │ CORE SYSTEM │ │ │ │ Domain Logic │ │ State │ │ Business Rules │ └─────────────────┘ ``` The important part isn't the box. It's the **invariant**. ### 1. Admission The Core decides what it needs to process. The outside world does not. Events can be validated, authenticated, classified, throttled, rejected, or accepted before they cross the boundary. ### 2. Isolation External noise must not directly dictate the operational state of the Core. A burst outside the boundary should not automatically become a crisis inside it. This is where mechanisms such as rate limiting, buffering, queues, bulkheads, and circuit breakers may be used. They are not the Barzakh itself. They are tools used to enforce the boundary. ### 3. Deferral Rejected does not necessarily mean destroyed. An event may be: - processed immediately, - queued for later, - retried under controlled conditions, - quarantined, - dead-lettered, - or permanently rejected. The important decision is made **at the boundary**, rather than being pushed into the Core. ### And the most important rule: **The Core System should not need to know why the outside world is noisy.** It should only receive work that has crossed the boundary. That gives us something more valuable than another middleware component: **a separation of responsibility.** --- ### Why "Barzakh"? In Islamic terminology, *Barzakh* refers to a barrier or intermediary boundary between two realms. I'm borrowing the metaphor for architecture: **External World → Barzakh → Core** The Barzakh is where uncertainty, noise, and external chaos are dealt with before they become the Core's problem. Or, in less philosophical terms: > **Not everything knocking on the door gets invited into the living room.** --- ### Is this really the 24th GoF pattern? Strictly speaking? **No.** The original GoF catalog still has 23. But that's precisely why I call this the **unofficial 24th**. The original patterns mostly describe how software objects collaborate. Modern distributed systems have another problem: **How do we control what is allowed to cross a system boundary in the first place?** That problem deserves architectural thinking of its own. Maybe Barzakh isn't a new primitive. Maybe it's a new way of looking at primitives we already have. And perhaps that's what a good pattern should do: **give a name to a problem we've been solving repeatedly without realizing we were solving the same problem.** --- Production systems may need to run 24/7. But that doesn't mean every external event deserves a direct line to the Core. **Protect the Core.** **Own the boundary.** **Let the chaos stay outside until it earns admission.** Welcome to Barzakh. #SoftwareArchitecture #SystemDesign #DistributedSystems #Microservices #SoftwareEngineering #DesignPatterns #BackendEngineering #Architecture #TechHumor

Komentar

Postingan populer dari blog ini

Work Fast, But Don’t Rush: The Difference Between Being Productive and Looking Busy