Skip to content

Commit 2e70f04

Browse files
committed
docs: improve markdown formatting and code examples readability
1 parent a9af9cd commit 2e70f04

File tree

1 file changed

+61
-44
lines changed

1 file changed

+61
-44
lines changed

2_oop_relationships/README.md

+61-44
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ In UML there are five different types of relationships:
44
**Association** , **Aggregation** , **Composition** , **dependency** , and **inheritance**.
55

66
## 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)
1521

1622

1723

@@ -43,29 +49,36 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
4349
`uni-directional` association:
4450
- only one of the classes is aware of the relationship.
4551

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+
```
5261

5362
`bi-directional` association:
5463
- 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+
```
6982

7083

7184

@@ -83,13 +96,14 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
8396
- I have an object which I've borrowed from someone else.
8497
- When Foo dies, Bar may live on.
8598
- <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) {
90103
this.bar = bar;
91-
}
92104
}
105+
}
106+
```
93107
94108
---
95109
# Composition
@@ -106,11 +120,12 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
106120
- I own an object and I am responsible for its lifetime.
107121
- When Foo dies, so does Bar.
108122
- <img src="./assets/composition_uml.PNG"/>
109-
-
123+
- ```dart
110124
class Foo {
111125
// Must be final
112126
final Bar bar = Bar();
113127
}
128+
```
114129
115130
---
116131
# Comparison
@@ -143,6 +158,7 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
143158
144159
- example 2:
145160
- Example of Composition
161+
```dart
146162
147163
//Car must have Engine
148164
class Car {
@@ -155,22 +171,23 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
155171
156172
//Engine Object
157173
class Engine {}
158-
174+
```
159175
160176
- Example of Aggregation
161-
162-
//Team
163-
class Team {
177+
178+
```dart
179+
//Team
180+
class Team {
164181
//players can be 0 or more
165182
List players;
166183
167184
Team () {
168185
players = ArrayList();
169186
}
170-
}
171-
//Player Object
172-
class Player {}
173-
187+
}
188+
//Player Object
189+
class Player {}
190+
```
174191
175192
# Extra
176193
@@ -184,7 +201,7 @@ NB: See Fowler's definition - the key is that Bar is semantically related to Foo
184201
185202
186203
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>
188205
189206
190-
<img src="./assets/association.PNG"/>
207+
<img src="assets/association.PNG"/>

0 commit comments

Comments
 (0)