Showing articles from Design Patterns tag

Design Patterns - Proxy Pattern
The Proxy Pattern, and the last article in the design patterns series, now that I've finished reading Head First Design Patterns.

Design Patterns - State Pattern
The State Pattern: replacing an enum and its switch statements with a class per state, so a game unit acts differently when it's alive or dead.

Design Patterns - Composite Pattern
The Composite Pattern: tactical moves made of submoves, as a tree that the game treats as a single move.

Design Patterns - Iterator Pattern
The Iterator Pattern: one loop over two factions' orders, whether they're stored in a List or an array, and then the same with IEnumerable.

Design Patterns - Template Method Pattern
The Template Method Pattern: a base renderer that fixes the drawing order, while the 2D and 3D renderers fill in each step.

Design Patterns - Facade Pattern
The Facade Pattern: one LoadMap() call on a StorageFacade instead of juggling the CD, hard disk and memory classes yourself.

Design Patterns - Adapter Pattern
The Adapter Pattern: making a third-party Structure behave like our own IBuilding, the way a travel plug adapter does.

Design Patterns - Command Pattern
The Command Pattern: UI buttons that run commands without knowing about game units, with undo for the last action.

Design Patterns - Generic Singleton Pattern
A generic Singleton base class that creates its instance through the private constructor with reflection, worked out with readers' help.

Design Patterns - Singleton Pattern
The Singleton Pattern: a single GraphicsCard instance, why the simple version isn't thread-safe, and a lazy, thread-safe version with a nested class.

Design Patterns - Abstract Factory Pattern
The Abstract Factory Pattern: one GameUnit class per unit type, configured per faction by a factory passed in at runtime, and how it differs from Factory Method.

Design Patterns - Factory Method Pattern
The Factory Method Pattern: an abstract InfantryFactory building, with one subclass per faction deciding which units to create.

Design Patterns - Decorator Pattern
The Decorator Pattern: wrapping a building in upgrades like turrets and lasers instead of a class for every combination, with the Open/Closed Principle.

Design Patterns - Observer/Event Pattern
The Observer Pattern the .NET way: replacing the subject and observer interfaces with an event and a custom EventArgs class.

Design Patterns - Observer Pattern
The Observer Pattern: game screens subscribe to units through IObserver and ISubject, so new displays need no changes to the unit.

Design Patterns - Strategy Pattern
The Strategy Pattern, explained with a Command & Conquer-style game: shooting behaviours as interchangeable classes instead of copied or overridden code.

Long Absence - Design Patterns
Back after a break, reading Head First Design Patterns, and starting a series with one post per pattern.