Behavioural Patterns

Behavioural Patterns

Behavioural Patterns focus on how objects cooperate and pass work along, using techniques like commands or observers to reduce tight links and simplify testing.

Chain of Responsibility Pattern: Leave Request Approval Chain

Explains the Chain of Responsibility Pattern in C# using a leave approval analogy to show how requests are passed until someone handles them.

Command Pattern: Voice Assistant (e.g. Alexa, Siri)

Explains the Command Pattern in C# using the voice assistant analogy to show how requests are wrapped as objects and executed separately.

Interpreter Pattern: Language Translator

Explains the Interpreter Pattern in C# using the language interpreter analogy, showing how structured input can be evaluated using grammar rules.

Iterator Pattern: Elevator Stopping at Each Floor

Explains the Iterator Pattern in C# using the elevator and floor analogy to show how to move through collections without knowing their internal structure.

Mediator Pattern: Air Traffic Controller

Explains the Mediator Pattern in C# using an air traffic controller analogy, showing how to decouple objects by routing communication through a central mediator.

Memento Pattern: Game Save Feature

Explains the Memento Pattern in C# using the save game feature analogy, showing how to capture and restore object state safely.

Null Object Pattern: Default Voicemail Greeting

Explains how the Null Object Pattern avoids null checks using a default voicemail analogy.

Observer Pattern: YouTube Subscriber

Explains the Observer Pattern in C# using the YouTube subscription analogy, including how to implement subjects and observers.

State Pattern: Phone Modes - Silent, Vibrate, Normal

Explains the State Pattern in C# using the phone mode analogy, showing how internal state determines behaviour and how to isolate logic with state classes.

Strategy Pattern: Navigation App Routes

Explains the Strategy Pattern in C# using the navigation app analogy, showing how to swap interchangeable algorithms without changing business logic.

Template Method Pattern: Baking a Cake from a Recipe

Explains the Template Method Pattern in C# using the cake recipe analogy, showing how to define a structure with customisable steps.

Visitor Pattern: Visitors at a Company Office

Explains the Visitor Pattern in C# using a company visitor analogy, where different types of visitors interact with departments without modifying them.

Specification Pattern: Club Entry Rules

The Specification Pattern is a design approach in C# for defining business rules as modular, reusable objects that can be easily combined.

Pipeline / Middleware Pattern: Assembly Line in a Factory

The Pipeline (Middleware) Pattern is a flexible design approach in C# that allows data or requests to pass through a chain of reusable steps, where each step can modify, inspect, or terminate the flow.