File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 2
2
# -*- coding: utf-8 -*-
3
3
4
4
"""
5
+ *What is this pattern about?
6
+ This pattern aims to minimise the number of objects that are needed by
7
+ a program at run-time. A Flyweight is an object shared by multiple
8
+ contexts, and is indistinguishable from an object that is not shared.
9
+
10
+ The state of a Flyweight should not be affected by it's context, this
11
+ is known as its intrinsic state. The decoupling of the objects state
12
+ from the object's context, allows the Flyweight to be shared.
13
+
14
+ *What does this example do?
15
+ The example below sets-up an 'object pool' which stores initialised
16
+ objects. When a 'Card' is created it first checks to see if it already
17
+ exists instead of creating a new one. This aims to reduce the number of
18
+ objects initialised by the program.
19
+
5
20
*References:
6
21
http://codesnipers.com/?q=python-flyweights
7
22
You can’t perform that action at this time.
0 commit comments