Junior — Middle
Can you name the main creational design patterns and their features?
sobes.tech AI
Answer from AI
Main creational design patterns in C# and their features:
-
Singleton
- Ensures that a class has only one instance.
- Provides a global point of access to this instance.
-
Factory Method
- Defines an interface for creating an object, but allows subclasses to alter the type of objects that will be created.
-
Abstract Factory
- Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
-
Builder
- Allows step-by-step creation of complex objects.
- Separates the construction of a complex object from its representation.
-
Prototype
- Creates new objects by copying existing ones (cloning).
Each of these patterns helps manage object creation, making the code more flexible and maintainable.