Design Pattern
August 24, 2023Less than 1 minute
Design Pattern
GoF 23
Creational Design Patterns 创建型
Structural Design Patterns 结构型
- Decorator Pattern: The Decorator Pattern allows you to add new behaviors or responsibilities to objects without altering their existing code. It’s like adding layers of wrapping to a gift.
- Adapter Pattern: The Adapter Pattern allows one class to work with another class that has a different interface. It acts as a bridge between two incompatible interfaces.
- Proxy Pattern: The Proxy Pattern provides a placeholder of another object to control access to it. It’s like having a remote control for a TV; you interact with the remote instead of directly with the TV.
Behavioral Design Patterns 行为型
- Observer Pattern: The Observer Pattern establishes a relationship where one thing (called the subject) is watched by several other things (knows as observers).
- State Pattern: The State Pattern enables an object to modify how it behaves as its internal state changes.
- Strategy Pattern: The Strategy Pattern involves defining a group of different algorithm and making it possible to choose and switch between them as needed while a program is running.
- Template Method Pattern: The Template Method is like providing a recipe with some fixed steps (skeleton), but allowing different cooks (subclasses) to add their unique ingredients or flavors (override specific parts) without changing the basic cooking instructions (overall structure).