Skip to content

Commit 770687b

Browse files
committed
Insights added, tasks edited
1 parent 075cada commit 770687b

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

module4/06-exercise-cars.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ ___
66

77
## Cars
88

9-
1. <!-- .element: class="fragment fade-in" --> Design proper abstraction (interfaces)
10-
2. <!-- .element: class="fragment fade-in" --> Apply inheritance
11-
3. <!-- .element: class="fragment fade-in" --> Fix encapsulation
12-
4. <!-- .element: class="fragment fade-in" --> Use polymorphism to represent every type of car, using a single pointer
13-
5. <!-- .element: class="fragment fade-in" --> Fix diamond problem
14-
6. <!-- .element: class="fragment fade-in" --> Fix potential memory leaks
15-
7. <!-- .element: class="fragment fade-in" --> Think about the way of keeping engines in cars. Should they be kept by a value, reference or a pointer (what kind of pointer)?
16-
8. <!-- .element: class="fragment fade-in" --> Is this code testable?
17-
18-
### [View task in repo](https://github.com/coders-school/Cars.git)
9+
### [Repo](https://github.com/coders-school/Cars.git)
1910
<!-- .element: class="fragment fade-in" -->
11+
12+
1. <!-- .element: class="fragment fade-in" --> Zaproponuj właściwą abstrakcję (interfejs)
13+
2. <!-- .element: class="fragment fade-in" --> Zastosuj dziedziczenie
14+
3. <!-- .element: class="fragment fade-in" --> Napraw enkapsulację
15+
4. <!-- .element: class="fragment fade-in" --> Użyj polimorfizmu, aby za pomocą wskaźnika na klasę bazową reprezentować dowolny typ samochodu
16+
17+
___
18+
19+
## Cars - pytania
20+
21+
1. <!-- .element: class="fragment fade-in" --> Jak trzymać silniki? Przez wartość, referencję, czy wskaźnik?
22+
2. <!-- .element: class="fragment fade-in" --> Czy jest problem diamentowy?
23+
3. <!-- .element: class="fragment fade-in" --> Czy są wycieki pamięci?
24+
4. <!-- .element: class="fragment fade-in" --> Czy kod jest testowalny?

module4/07-insights.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ ___
1212
class A {
1313
virtual void f();
1414
virtual void g();
15+
virtual ~A();
1516
int a;
17+
double b;
1618
};
1719
```
1820
1921
```text
20-
stos: | *vptr | int a |
22+
stos: | *vptr | int a | double b |
2123
|
2224
V
23-
sterta: | void (*f)() | void (*g)() |
24-
| |
25-
V V
26-
A::f A::g
25+
sterta: | void (*f)() | void (*g)() | destructor |
26+
| | |
27+
V V V
28+
A::f A::g A::~()
2729
```
2830

2931
___

module4/08-homework.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ ___
88

99
You can work in groups or individually. Fork the Cars repo and submit a Pull Request after you have finished.
1010

11-
1. <!-- .element: class="fragment fade-in" --> (4 XP) Create <code>InvalidGear</code> exception. It should be thrown when someone tries eg. change a gear from 5 to R. It should inherit from one of STL exceptions
12-
2. <!-- .element: class="fragment fade-in" --> (2 XP per fix) Fix interfaces to be easy to use correctly and hard to use incorrectly (like <code>accelerate(-999)</code>)
13-
3. <!-- .element: class="fragment fade-in" --> (10 XP - optional) Write a proper unit tests to this code
14-
4. <!-- .element: class="fragment fade-in" --> Read one of below articles. It will be useful for the next lesson
15-
16-
* <!-- .element: class="fragment fade-in" --> <a href="https://www.samouczekprogramisty.pl/solid-czyli-dobre-praktyki-w-programowaniu-obiektowym/">SOLID czyli dobre praktyki w programowaniu obiektowym</a>
11+
1. (5 XP) Utwórz wyjątek <code>InvalidGear</code>. Ma on być rzucany wtedy, gdy ktoś próbuje w niewłaściwy sposób zmienić bieg, np. z 5 na R. Ma on dziedziczyć po `std::logic_error`.
12+
2. (10 XP) Napisz testy jednostkowe do tego kodu. W szczególności przetestuj rzucanie powyższego wyjątku. Skonfiguruj odpowiednio CMake'a.
13+
3. (0 XP) Napraw interfejs, aby był łatwy w poprawnym użyciu i trudny do niewłaściwego użycia (np. <code>accelerate(-999)</code>). Bez punktów, bo ciężko zautomatyzować tak ogólne zadanie i każdy wymyśli tutaj coś innego.
14+
4. Przeczytaj artykuł [SOLID czyli dobre praktyki w programowaniu obiektowym](https://www.samouczekprogramisty.pl/solid-czyli-dobre-praktyki-w-programowaniu-obiektowym/)

0 commit comments

Comments
 (0)