Part 1 of 6 · 1 min read
Why this page comes fifth
In this module you will
- Explain the Prototype pattern and when copying beats constructing.
- Tell a shallow copy from a deep copy, with a bug that shows the difference.
- Write a copy constructor and use it in a prototype registry.
- Say why Effective Java advises against
cloneandCloneable. - Choose between prototype, factory and builder for a given case.
Modules 1 to 3 made new objects from nothing. This page makes them from an existing one, which is a good fit when objects come in a few ready-made combinations. The sources are "Design Patterns" (GoF) chapter 3 and "Effective Java" (EJ) Item 13. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.