@@ -3,23 +3,25 @@ also Known as `wrapper`
3
3
> - structural pattern.
4
4
> - allows a user to add new functionality to an existing object without altering (Changing) its structure.
5
5
6
- <table >
6
+ <table align = " center " >
7
7
<tr>
8
- <td><img src = "assets/Decorator_UML_class_diagram.png" ></td>
8
+ <td><img style="background-color:#33475b" src = "assets/Decorator_UML_class_diagram.png" ></td>
9
9
<td><img src = "assets/decorator_structure.png" ></td>
10
10
</tr>
11
11
</table >
12
12
13
13
## Sections
14
14
- [ Definitions] ( #Definitions )
15
- - [ What problems can it solve? ] ( #What-problems-can-it-solve? )
16
- - [ What solution does it describe? ] ( #What-solution-does-it-describe? )
15
+ - [ What problems can it solve] ( #What-problems-can-it-solve )
16
+ - [ What solution does it describe] ( #What-solution-does-it-describe )
17
17
- [ Examples] ( #Examples )
18
18
- [ Shape Decorator Example] ( #Shape-Decorator-Example )
19
19
- [ Windows Decorator Example] ( #Windows-Decorator-Example )
20
20
- [ Email Notifier Example] ( #Email-Notifier-Example )
21
+ - [ Coffee Decorator Example] ( #Coffee-Decorator-Example )
21
22
- [ TO DO] ( #TO-DO )
22
23
- [ Summery] ( #Summery )
24
+ - [ Sources] ( #Sources )
23
25
24
26
25
27
## Definitions
@@ -44,23 +46,23 @@ also Known as `wrapper`
44
46
- because an object's behavior can be augmented without defining an entirely new object.
45
47
46
48
47
- ## What problems can it solve?
49
+ ## What problems can it solve
48
50
1 . Responsibilities should be added to (and removed from) an object dynamically at run-time.
49
51
2 . A flexible alternative (Changing) to subclassing for extending functionality should be provided.
50
52
- When using subclassing, different subclasses extend a class in different ways.
51
53
- ` But an extension is bound (restricted) to the class at compile-time and can't be changed at run-time. `
52
54
53
- ## What solution does it describe?
55
+ ## What solution does it describe
54
56
1 . implement the interface of the extended (decorated) object (Component) transparently by forwarding all requests to it
55
57
perform additional functionality before/after forwarding a request.
56
58
2 . This allows working with different Decorator objects to extend the functionality of an object dynamically at run-time.
57
59
58
60
> See also the UML class and sequence diagram below.
59
- <center> <img src = " assets/Decorator_Design_Pattern_UML.jpg " ></center >
61
+ <p align=" center" > <img src = " assets/Decorator_Design_Pattern_UML.jpg " ></p >
60
62
61
63
## Examples
62
64
63
- ### Shape Decorator
65
+ ### Shape Decorator Example
64
66
> in this example we will decorate a shape with some color
65
67
> without alter (Change) shape class.
66
68
@@ -278,6 +280,9 @@ void main(List<String> args) {
278
280
### Email Notifier Example
279
281
- Example in dart: <a href =" email_notifier_example/ " target =" _blank " > click here </a >
280
282
283
+ ### Coffee Decorator Example
284
+ - Example in dart: <a href =" coffee_decorator_example.dart " target =" _blank " > click here </a >
285
+ - Example Source: https://github.com/scottt2/design-patterns-in-dart/tree/master/decorator
281
286
282
287
## TO Do
283
288
https://refactoring.guru/design-patterns/decorator
0 commit comments