File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
"""
3
- Reference: https://en.wikipedia.org/wiki/Decorator_pattern
3
+ *What is this pattern about?
4
+ The Decorator pattern is used to dinamically add a new feature to an
5
+ object without changing its implementation. It differs from
6
+ inheritance because the new feature is added only to that particular
7
+ object, not to the entire subclass.
8
+
9
+ *What does this example do?
10
+ This example shows a way to add formatting options (boldface and
11
+ italic) to a text by appending the corresponding tags (<b> and
12
+ <i>). Also, we can see that decorators can be applied one after the other,
13
+ since the original text is passed to the bold wrapper, which in turn
14
+ is passsed to the italic wrapper.
15
+
16
+ *Where is the pattern used practically?
17
+ The Grok framework uses decorators to add functionalities to methods,
18
+ like permissions or subscription to an event:
19
+ http://grok.zope.org/doc/current/reference/decorators.html
20
+
21
+ *References:
22
+ https://sourcemaking.com/design_patterns/decorator
4
23
"""
5
24
6
25
You can’t perform that action at this time.
0 commit comments