Software Design Patterns: Introduction

Throughout my career, I kept finding myself writing code for solutions that, on the surface, looked increasingly similar to things I’d written before. What I didn’t realise at the time was that I was inadvertently implementing patterns that have existed in software engineering for decades—the Gang of Four design patterns.
Once I noticed this, I discovered most of these patterns were already well-documented on sites like Wikipedia. But I’d never actually sat down to learn them properly from scratch, stepping through each one with a debugger to understand how they really work.
There was another problem: working examples in C# were almost impossible to find. Most resources contained diagrams only, and the code samples that did exist were written in Java or other languages. What I wanted was dependency-free sample code that I could set a breakpoint in and watch execute, line by line.
So I sat down and worked through a 15-hour Pluralsight course on the subject, writing up each pattern as I went. This gave me both a learning exercise and a reference to return to later.
Working C# examples for every pattern in this series are available on GitHub:
The Gang of Four patterns
The patterns fall into three broad categories:
| Category | Description |
|---|---|
| Creational | Focuses on object creation mechanisms, creating objects in a manner suited to the situation |
| Structural | Concerned with how classes and objects are composed together to form larger structures |
| Behavioural | Deals with object interaction and the delegation of responsibility |
Rather than one enormous post listing every pattern, each one gets its own detailed write-up:
Related Posts
2024-01-28
2024-01-14