aboutsummaryrefslogtreecommitdiff
path: root/img/decorator-design-pattern.puml
blob: 2bc406b3e14c29f4b6d074450d19dc93aa1cb70f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@startuml
!include theme.ipuml
skinparam style strictuml
skinparam Linetype ortho

class Client
class Component <<interface>> {
	+ execute()
	--
}
class ConcComponent as "Concrete\nComponent" {
	...
	--
	+ execute()
}
class BaseDecorator as "Base Decorator" {
	- wrappee: Component
	+ BaseDecorator(c: Component)
	+ execute()
}
class ConcDecorator as "Concrete\nDecorators" {
	...
	--
	+ execute()
	+ extra()
}

hide Client members
hide circle

Client --> Component
Component <|.. ConcComponent
Component <|.. BaseDecorator
Component <--o BaseDecorator
BaseDecorator <|-- ConcDecorator

ConcComponent -right[hidden] BaseDecorator

note right of Client
	a = <b>new</b> ConcComponent()
	b = <b>new</b> ConcDecorator1(a)
	c = <b>new</b> ConcDecorator1(b)
	c.execute()
	// Decorator -> Decorator -> Component
end note

note right of BaseDecorator::BaseDecorator
	wrappee = c
end note

note right of BaseDecorator::execute
	wrappee.execute()
end note

note right of ConcDecorator::execute
	super::execute()
	extra()
end note

@enduml

" referenced from <https://github.com/algamza/algamza.github.io>