Junior — Middle
Can you list the main categories of design patterns and their examples?
sobes.tech AI
Answer from AI
The main categories of design patterns are divided into three groups:
-
Creational — responsible for creating objects while hiding the details of their creation.
- Examples: Singleton, Factory Method, Abstract Factory, Builder, Prototype.
-
Structural — help organize classes and objects into larger structures.
- Examples: Adapter, Decorator, Facade, Composite, Proxy.
-
Behavioral — define ways objects interact.
- Examples: Observer, Strategy, Command, Iterator, State.
For example, Singleton guarantees that a class has only one instance, while Observer allows objects to subscribe to events of another object.