Added real world example for Flyweight.

This commit is contained in:
Ilkka Seppälä
2015-02-25 16:22:37 +02:00
parent 093fc1f824
commit 599e6cdeb2

View File

@ -178,6 +178,9 @@
* many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed * many groups of objects may be replaced by relatively few shared objects once extrinsic state is removed
* the application doesn't depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects. * the application doesn't depend on object identity. Since flyweight objects may be shared, identity tests will return true for conceptually distinct objects.
**Real world examples:**
* [java.lang.Integer#valueOf(int)](http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#valueOf%28int%29)
## <a name="proxy">Proxy</a> [&#8593;](#list-of-design-patterns) ## <a name="proxy">Proxy</a> [&#8593;](#list-of-design-patterns)
**Intent:** Provide a surrogate or placeholder for another object to control access to it. **Intent:** Provide a surrogate or placeholder for another object to control access to it.