Skip to content

Commit d37c367

Browse files
committed
Create 'about' document
1 parent 07431ed commit d37c367

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Exercises to train your C++11/14/17 (and then some).
66
[![Build status](https://xtofl.visualstudio.com/cpp11exercises/_apis/build/status/cpp11exercises-CI)](https://xtofl.visualstudio.com/cpp11exercises/_build/latest?definitionId=2)
77
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e1556f3ddf3645fe98d1fb06bf011b1c)](https://app.codacy.com/app/kristoffel-pirard/cpp11training?utm_source=github.com&utm_medium=referral&utm_content=xtofl/cpp11training&utm_campaign=Badge_Grade_Dashboard)
88

9+
## About
10+
11+
This repo is intended as a resource to use during C++ trainings. If you're curious about how it came
12+
to be, take a look at [about.md](about.md).
13+
914
## Getting started
1015

1116
### Linux

about.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Exercises for the masses
2+
3+
## History
4+
5+
Working in C++ around the year 2010 was very exciting. The language was about
6+
to receive some vast new impulses, promising better semantics, performance, …
7+
8+
In 2016, I was lucky enough to work in an environment that lived on the edge:
9+
constantly following the latest (Microsoft) compiler versions, and writing C++
10+
programs according to the latest and greatest idioms.
11+
12+
All of this happiness had to be shared. That’s why my employer, Sioux Embedded
13+
Systems, asked if anyone would be able to create a C++11/14 ramp-up course for
14+
my colleagues. Of course I bit.
15+
16+
The budget: 5 days of preparation - a challenge for me. It seemed a vast
17+
undertaking, given the fact that I hadn’t been giving training, nothing ‘free’
18+
could be found. So I decided I would borrow free and open source presentations,
19+
and create exercises myself. But how?
20+
21+
As it happened, there also was a gap in the knowledge of unit testing
22+
frameworks. So why not kill two birds with one stone? Fond of TDD, I had grown
23+
quite familiar with the googletest framework. So I decided to create a bunch of
24+
failing unit tests that had to be ‘fixed’ using C++11/14 features.
25+
26+
Since I was to take all my course material from the internet, I thought it only
27+
fitting to give back. So I started creating the course in the open on
28+
https://github.com/xtofl/cpp11training/.
29+
30+
## Overview
31+
32+
### Repo structure
33+
34+
* Presentations are stored in the `slides/` directory. There's also a
35+
[readme](slides/README.md) to explain its contents.
36+
* Exercises are stored per topic under the `src/` folder; within each topic,
37+
exercise source files are numbered.
38+
* Each topic file contains a number of `TEST` cases. Each of these cases represents
39+
an exercise. In the comments, I try to explain what you're supposed to do (TODO),
40+
what you're supposed to learn from this exercise (GOAL), and may add some HINTs.
41+
42+
### Exercise Example
43+
44+
For instance, one of the first exercises you'll encounter is about using the
45+
range-based-for feature introduced in C++11.
46+
47+
```c++
48+
TEST(range_based_for, DISABLED_we_can_iterate_over_a_collection)
49+
{
50+
int result = 0;
51+
// TODO: extend the Range class so that it acts as a
52+
// real 'range' and can be used in a range based for loop.
53+
//
54+
// GOAL: understand the working of range-based for loop, and
55+
// adapt existing classes to it
56+
//
57+
// HINT: This is a harder problem: you need to provide
58+
// a free begin(const Range&) and end(const Range&) function
59+
// that returns an iterator-like object.
60+
//
61+
#ifdef solv
62+
for (const auto &element : Range{ 1, 11 })
63+
{
64+
result += element;
65+
}
66+
#endif
67+
EXPECT_EQ(55, result);
68+
}
69+
```
70+
71+
As you'll see, the test will
72+
be compiled, but the `DISABLED_` prefix in its name will prevent gtest from
73+
executing it. Removing the prefix 'activates' the test and makes it run,
74+
but fail:
75+
76+
![failing-test.png](failing-test.png)
77+
78+
Another example: one to learn using the `transform` algorithm:
79+
80+
```c++
81+
TEST(apply_transform, DISABLED_join_two_input_ranges)
82+
{
83+
const std::vector<std::string> keys{ {"two", "five", "ten", "forty"} };
84+
const std::vector<int> values{ {2, 5, 10, 40} };
85+
86+
std::vector<std::string> numbers;
87+
// TODO: transform keys and values into
88+
// this python-key-value syntax
89+
// GOAL: see that `transform` can accept two ranges
90+
// and 'zip' them together
91+
ASSERT_EQ(keys.size(), numbers.size());
92+
EXPECT_EQ("two: 2", numbers[0]);
93+
EXPECT_EQ("five: 5", numbers[1]);
94+
EXPECT_EQ("ten: 10", numbers[2]);
95+
EXPECT_EQ("forty: 40", numbers[3]);
96+
}
97+
```
98+
99+
## Future
100+
101+
Meanwhile we're 2020, and I have given this training about 5 times. Everytime,
102+
the overall response is positive about offering running code in the form of
103+
isolated unit tests. The fun part for me is that whenever someone finds a
104+
mistake, I can kindly ask them to fix it and create a merge request.
105+
106+
And it has proven to be needed. What is also needed: some of the exercises are
107+
a little 'far fetched', and may be replaced by more down to earth subjects.
108+
Although on every occasion I am able to improve the guidelines, add some
109+
exercises and the lot, this body of exercises still needs a lot of guidance.
110+
111+
I'm hoping that some day, this effort will be picked up and improved by 'the
112+
masses'. For I'm convinced that good and affordable programming education is
113+
an important ingredient for an inclusive world.

failing-test.png

33.5 KB
Loading

0 commit comments

Comments
 (0)