Skip to content

Commit c860aa8

Browse files
committed
doc: UML diagram
1 parent 665da9d commit c860aa8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

chapter02_observer/readme.md

+34
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,40 @@ for instance, in Django.
99
As I wrote out the code I found it very appealing that I did not need
1010
to change the subject at all to add new observers.
1111

12+
### Class Diagram
13+
14+
```mermaid
15+
16+
classDiagram
17+
18+
Subject <-- Observer : observers
19+
Subject1 <-- Observer1 : subject
20+
Subject1 <-- Observer2 : subject
21+
Subject <|-- Subject1
22+
Observer <|-- Observer1
23+
Observer <|-- Observer2
24+
Subject : attach(o)
25+
Subject : detach(o)
26+
Subject: notify()
27+
class Observer{
28+
+update()
29+
}
30+
class Subject1{
31+
state
32+
get_state()
33+
set_state()
34+
}
35+
class Observer1{
36+
state
37+
update()
38+
}
39+
class Observer2{
40+
state
41+
update()
42+
}
43+
44+
```
45+
1246
## Running the code
1347

1448
```bash

0 commit comments

Comments
 (0)