@@ -4,14 +4,20 @@ In UML there are five different types of relationships:
4
4
** Association** , ** Aggregation** , ** Composition** , ** dependency** , and ** inheritance** .
5
5
6
6
## Sections
7
- 1 . [ Symbols] ( #Symbols )
8
- 1 . [ Association] ( #Association )
9
- - [ Types] ( #Types )
10
- 1 . [ Aggregation] ( #Aggregation )
11
- 1 . [ Composition] ( #Composition )
12
- 1 . [ Comparison] ( #Comparison )
13
- 1 . [ Example] ( #Example )
14
- 1 . [ Extra] ( #Extra )
7
+ - [ OOP Relationships] ( #oop-relationships )
8
+ - [ Sections] ( #sections )
9
+ - [ Symbols] ( #symbols )
10
+ - [ Association] ( #association )
11
+ - [ Types] ( #types )
12
+ - [ Aggregation] ( #aggregation )
13
+ - [ example:] ( #example )
14
+ - [ Aggregation:] ( #aggregation-1 )
15
+ - [ Composition] ( #composition )
16
+ - [ example:] ( #example-1 )
17
+ - [ Composition:] ( #composition-1 )
18
+ - [ Comparison] ( #comparison )
19
+ - [ Example] ( #example-2 )
20
+ - [ Extra] ( #extra )
15
21
16
22
17
23
@@ -43,29 +49,36 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
43
49
` uni-directional ` association:
44
50
- only one of the classes is aware of the relationship.
45
51
46
- - class printer{
47
- print(String value)
48
- }
49
- class Teacher{
50
- printExam(Printer printer)=> printer.print("");
51
- }
52
+ ``` dart
53
+ class printer{
54
+ print(String value)
55
+ }
56
+
57
+ class Teacher{
58
+ printExam(Printer printer)=> printer.print("");
59
+ }
60
+ ```
52
61
53
62
` bi-directional ` association:
54
63
- both classes know about each other and with
55
- - <img src =" ./assets/association_uml.PNG " />
56
- -
57
- class Student{
58
- List<Teacher> teachers;
59
- assignATempTeacher(Teacher teacher){
60
- teacher.assignAHomeWork(homeWork);
61
- }
62
- }
63
- class Teacher{
64
- List<Student> students;
65
- assignExamToStudent(Student student,Exam exam){
66
- student.setExam(exam);
67
- }
68
- }
64
+
65
+
66
+ <img src =" assets/association_uml.PNG " />
67
+
68
+ ``` dart
69
+ class Student{
70
+ List<Teacher> teachers;
71
+ assignATempTeacher(Teacher teacher){
72
+ teacher.assignAHomeWork(homeWork);
73
+ }
74
+ }
75
+ class Teacher{
76
+ List<Student> students;
77
+ assignExamToStudent(Student student,Exam exam){
78
+ student.setExam(exam);
79
+ }
80
+ }
81
+ ```
69
82
70
83
71
84
@@ -83,13 +96,14 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
83
96
- I have an object which I've borrowed from someone else.
84
97
- When Foo dies, Bar may live on.
85
98
- <img src =" ./assets/aggregation_uml.PNG " />
86
- -
87
- class Foo {
88
- Bar bar;
89
- Foo(Bar bar) {
99
+ - ``` dart
100
+ class Foo {
101
+ Bar bar;
102
+ Foo(Bar bar) {
90
103
this.bar = bar;
91
- }
92
104
}
105
+ }
106
+ ```
93
107
94
108
---
95
109
# Composition
@@ -106,11 +120,12 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
106
120
- I own an object and I am responsible for its lifetime.
107
121
- When Foo dies, so does Bar.
108
122
- <img src="./assets/composition_uml.PNG"/>
109
- -
123
+ - ```dart
110
124
class Foo {
111
125
// Must be final
112
126
final Bar bar = Bar();
113
127
}
128
+ ```
114
129
115
130
---
116
131
# Comparison
@@ -143,6 +158,7 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
143
158
144
159
- example 2:
145
160
- Example of Composition
161
+ ```dart
146
162
147
163
//Car must have Engine
148
164
class Car {
@@ -155,22 +171,23 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
155
171
156
172
//Engine Object
157
173
class Engine {}
158
-
174
+ ```
159
175
160
176
- Example of Aggregation
161
-
162
- //Team
163
- class Team {
177
+
178
+ ```dart
179
+ //Team
180
+ class Team {
164
181
//players can be 0 or more
165
182
List players;
166
183
167
184
Team () {
168
185
players = ArrayList();
169
186
}
170
- }
171
- //Player Object
172
- class Player {}
173
-
187
+ }
188
+ //Player Object
189
+ class Player {}
190
+ ```
174
191
175
192
# Extra
176
193
@@ -184,7 +201,7 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
184
201
185
202
186
203
187
- - <div style =" width :664px " > <strong style =" display :block ;margin :12px 0 4px " ><a href =" https://slideplayer.com/slide/5119872/ " title =" CMSC 132: Object-Oriented Programming II " target =" _blank " >CMSC 132: Object-Oriented Programming II</a ></strong ><iframe src =" https://player.slideplayer.com/16/5119872/ " width =" 664 " height =" 547 " frameborder =" 0 " marginwidth =" 0 " marginheight =" 0 " scrolling =" no " style =" border :1px solid #CCC ;border-width :1px 1px 0 " allowfullscreen ></iframe ><div style =" padding :5px 0 12px " ></div ></div >
204
+ <div style="width:664px"> <strong style="display:block;margin:12px 0 4px"><a href="https://slideplayer.com/slide/5119872/" title="CMSC 132: Object-Oriented Programming II" target="_blank">CMSC 132: Object-Oriented Programming II</a></strong><iframe src="https://player.slideplayer.com/16/5119872/" width="664" height="547" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC;border-width:1px 1px 0" allowfullscreen></iframe><div style="padding:5px 0 12px"></div></div>
188
205
189
206
190
- <img src =" ./ assets/association.PNG" />
207
+ <img src="assets/association.PNG"/>
0 commit comments