mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-16 14:59:21 +00:00
Added real world example of Prototype.
This commit is contained in:
@@ -87,6 +87,9 @@
|
||||
* to avoid building a class hierarchy of factories that parallels the class hierarchy of products; or
|
||||
* when instances of a class can have one of only a few different combinations of state. It may be more convenient to install a corresponding number of prototypes and clone them rather than instantiating the class manually, each time with the appropriate state
|
||||
|
||||
**Real world examples:**
|
||||
* [java.lang.Object#clone()](http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#clone%28%29)
|
||||
|
||||
## <a name="singleton">Singleton</a> [↑](#list-of-design-patterns)
|
||||
**Intent:** Ensure a class only has one instance, and provide a global point of access to it.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user