Design Patterns
Design patterns are well-known, engineering best practice solutions to common programming problems. Understanding these design patterns and when and how to apply them allows one to avoid "reinventing the wheel" and also provides a common language and set of conventions for handling these problems which increases understandability of the code that applies them. While these design patterns are well understood and solve many design problems, there are many design problems that require a combination of these patterns or that currently have no corresponding design pattern; however, studying these design patterns may nevertheless be useful for those cases, as well, by understanding the underlying reasoning and methodology that informs when to apply (or not apply) a specific design pattern.
These are patterns that (when applied properly) lead to well-designed code:
- The Builder Pattern - for simplifying configuration with many independent options
- The Factory Pattern - for separating construction details from the place of construction
- The Flyweight Pattern - for recycling objects rather than allocating them from scratch
These are patterns that are either overused or simply bad:
- The Singleton Anti-pattern - an explanation for why you should avoid this
Please see some of these sources for more patterns and alternative explanations / examples: