0
0
Software Engineeringknowledge~5 mins

Creational patterns (Singleton, Factory, Builder) in Software Engineering - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the Singleton pattern?
The Singleton pattern ensures a class has only one instance and provides a global point to access it. It is useful when exactly one object is needed to coordinate actions across a system.
Click to reveal answer
beginner
How does the Factory pattern help in object creation?
The Factory pattern creates objects without exposing the creation logic to the client. It lets the client use a common interface to create different types of objects, making the code flexible and easier to maintain.
Click to reveal answer
beginner
What problem does the Builder pattern solve?
The Builder pattern separates the construction of a complex object from its representation. It allows creating different representations step-by-step, making it easier to build objects with many parts or options.
Click to reveal answer
intermediate
Why use the Singleton pattern instead of a global variable?
Singleton controls the instance creation and can add behavior like lazy initialization or thread safety. Unlike global variables, it encapsulates the instance and can be extended or modified without affecting global state directly.
Click to reveal answer
beginner
Give a real-life example of the Factory pattern.
Imagine a car factory that produces different car models. The factory decides which car to build based on customer choice, hiding the details of how each car is made. The customer just requests a car type and gets the right model.
Click to reveal answer
Which creational pattern ensures only one instance of a class exists?
AFactory
BBuilder
CSingleton
DObserver
What is the main benefit of the Factory pattern?
ACreates objects without exposing creation logic
BEnsures only one instance exists
CBuilds complex objects step-by-step
DManages object lifecycle automatically
Which pattern is best for creating complex objects with many parts?
AFactory
BBuilder
CSingleton
DDecorator
What does the Singleton pattern provide besides a single instance?
AGlobal access point
BMultiple object types
CStep-by-step construction
DAutomatic memory management
In the Factory pattern, who decides which object to create?
AClient directly
BBuilder director
CSingleton instance
DFactory class
Explain the differences between Singleton, Factory, and Builder patterns with simple examples.
Think about how each pattern controls object creation differently.
You got /4 concepts.
    Describe a situation where using the Builder pattern is better than the Factory pattern.
    Consider complexity and flexibility in object creation.
    You got /4 concepts.