Middle
What design patterns do you know?
sobes.tech AI
Answer from AI
- Creational:
- Factory Method: Creating objects through an interface without specifying the exact class.
- Abstract Factory: Creating families of related or dependent objects without specifying their concrete classes.
- Builder: Step-by-step creation of a complex object, allowing the same construction process to create different representations.
- Prototype: Creating new objects by copying existing ones.
- Singleton: Ensures a class has only one instance and provides a global point of access to it.
- Structural:
- Adapter: Converts the interface of a class into another interface expected by clients.
- Bridge: Decouples an abstraction from its implementation so that the two can vary independently.
- Composite: Allows grouping objects into tree structures to represent hierarchies of part-whole relationships.
- Decorator: Dynamically adds responsibilities to an object by wrapping it in decorator objects.
- Facade: Provides a simplified interface to a complex subsystem.
- Flyweight: Enables sharing of large numbers of small objects to save memory by sharing common state.
- Proxy: Provides a surrogate or placeholder for another object to control access to it.
- Behavioral:
- Chain of Responsibility: Passes requests along a chain of handlers.
- Command: Encapsulates a request as an object, containing all information needed to perform it.
- Iterator: Provides a way to access elements of a collection sequentially without exposing its underlying representation.
- Mediator: Defines an object that encapsulates how a set of objects interact.
- Memento: Saves and restores an object's previous state without exposing its implementation details.
- Observer: Defines a one-to-many dependency so that when one object changes state, all its dependents are notified and updated automatically.
- State: Allows an object to alter its behavior when its internal state changes.
- Strategy: Encapsulates a family of algorithms, making them interchangeable.
- Template Method: Defines the skeleton of an algorithm in a method, deferring some steps to subclasses.
- Visitor: Represents an operation to be performed on elements of an object structure.
Also familiar with anti-patterns and SOLID principles.