Recall & Review
beginner
What is the main goal of the Flyweight pattern?
The Flyweight pattern aims to reduce memory usage by sharing common parts of objects instead of creating many similar objects.
Click to reveal answer
intermediate
In the Flyweight pattern, what are intrinsic and extrinsic states?
Intrinsic state is the shared, unchanging data stored inside the flyweight. Extrinsic state is the unique data passed from outside when using the flyweight.
Click to reveal answer
intermediate
How does the Flyweight pattern improve system scalability?
By sharing common data among many objects, it reduces memory consumption, allowing the system to handle more objects efficiently.
Click to reveal answer
beginner
Give a real-life example that illustrates the Flyweight pattern.
Imagine a text editor where each letter shares the same font style and size (intrinsic state), but their position on the screen (extrinsic state) is unique. This sharing saves memory.
Click to reveal answer
intermediate
What is a common structure used to manage flyweight objects?
A Flyweight Factory is used to create and manage flyweight objects, ensuring shared objects are reused instead of duplicated.
Click to reveal answer
What does the Flyweight pattern primarily help to reduce?
✗ Incorrect
The Flyweight pattern reduces memory usage by sharing common parts of objects.
Which state in the Flyweight pattern is shared among objects?
✗ Incorrect
Intrinsic state is the shared, unchanging data stored inside the flyweight.
What role does the Flyweight Factory play?
✗ Incorrect
The Flyweight Factory manages and reuses shared flyweight objects to save memory.
Which scenario best fits the Flyweight pattern?
✗ Incorrect
Flyweight is best when many objects share identical data to reduce memory use.
In the text editor example, what is an example of extrinsic state?
✗ Incorrect
Letter position is unique and passed externally, so it is extrinsic state.
Explain the Flyweight pattern and how it helps save memory in software systems.
Think about sharing common parts of objects instead of duplicating.
You got /4 concepts.
Describe the role of a Flyweight Factory and why it is important.
Consider how objects are created and reused.
You got /4 concepts.