Junior — Middle
Can you name common patterns in object-oriented design?
sobes.tech AI
Answer from AI
Common patterns in object-oriented design:
- Singleton — guarantees that a class has only one instance and provides a global point of access to it.
- Factory Method — defines an interface for creating an object but allows subclasses to alter the type of objects that will be created.
- Observer — allows objects to subscribe to events of another object and receive notifications about changes.
- Decorator — dynamically adds responsibilities to objects by wrapping them in other objects.
- Strategy — defines a family of algorithms, encapsulates each one, and makes them interchangeable.
- Adapter — allows objects with incompatible interfaces to work together.
- Command — encapsulates a request as an object, allowing parameterization of clients with different requests.
These patterns help create flexible, extendable, and maintainable architectures.