1/10
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is the Prototype pattern?
A pattern that creates new objects by copying an existing prototype.
What problem does Prototype solve in the slides?
Configuration objects are expensive to load, but we sometimes need duplicates.
Why is reloading the configuration each time a bad idea?
Because it is expensive and slow.
Why can’t the client just use the copy constructor through AppConfig?
Because AppConfig is abstract.
What method is added to the base class in Prototype?
A virtual clone() method.
What does FileConfig::clone() do?
It returns new FileConfig(*this).
What does DatabaseConfig::clone() do?
It returns new DatabaseConfig(*this).
When is Prototype especially useful?
When objects are expensive to create but easy to copy.
What advantage does Prototype give clients?
Clients can clone objects without knowing their exact concrete types.
How is Prototype different from Abstract Factory?
Prototype allows more flexible mixes by cloning prototypes, while Abstract Factory creates related families of products.
What is one consequence of Prototype?
It may reduce the need for subclassing or large factory hierarchies.