Design Patterns
Design patterns are standardised solutions to common software design problems. They represent best practices evolved over time, providing templates that allow developers to solve problems more efficiently and effectively.
Goal
The goal of using design patterns is to accelerate the development process by providing tested, proven development paradigms. Effective use of design patterns can result in code that is more reusable, scalable, and easier to understand and maintain.
Context
There are many different ways that code can be designed, each with different implications for system performance, security, and maintainability. By being aware of the different design patterns available, teams can choose the best for their context.
Patterns
Pattern | Description | Use Cases | Examples |
---|---|---|---|
Creational Patterns | Focus on class instantiation or object creation mechanisms. Examples include Singleton, Factory Method, and Builder patterns. | Used to create objects in a manner suitable to the situation. | Singleton, Factory Method, Builder. |
Structural Patterns | Deal with object composition or the structure of classes. Examples include Adapter, Decorator, and Composite patterns. | Used to form larger structures from individual parts, generally for easier maintenance and understanding. | Adapter, Decorator, Composite, Facade. |
behavioural Patterns | Concerned with object interaction and responsibility delegation. Examples include Observer, Strategy, and Command patterns. | Used to manage algorithms, relationships, and responsibilities between objects. | Observer, Strategy, Command. |
Concurrency Patterns | Address multi-threaded programming paradigms. Examples include Active Object, Monitor Object, and Half-Sync/Half-Async patterns. | Used to manage concurrent access to shared resources and ensure thread safety. | Active Object, Monitor Object, Half-Sync/Half-Async. |
Other Common Patterns | Additional patterns that are widely used in software development. | Used to address specific architectural, communication, and data management challenges. | MVC, CQRS, REST |
Inputs
Artifact | Description |
---|---|
User Stories | Detailed descriptions of the functionality, performance criteria, and interfaces needed for each component. |
Outputs
Artifact | Description | Benefits |
---|---|---|
Architectural Decision Records | Documents that capture the important architectural decisions made during the development process. | Provides a record of the project's architectural history and rationale. |
Anti-patterns
- Over-Engineering: Applying design patterns where they are not needed, leading to unnecessary complexity.
- Misapplication: Using a design pattern inappropriately, not aligned with its intended purpose.
- Pattern Explosion: Employing too many different patterns within a project, causing confusion and maintenance difficulties.