Skip to content

Commit

Permalink
Create 'about' document
Browse files Browse the repository at this point in the history
  • Loading branch information
xtofl committed Jul 26, 2020
1 parent 07431ed commit d37c367
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Exercises to train your C++11/14/17 (and then some).
[![Build status](https://xtofl.visualstudio.com/cpp11exercises/_apis/build/status/cpp11exercises-CI)](https://xtofl.visualstudio.com/cpp11exercises/_build/latest?definitionId=2)
[![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)

## About

This repo is intended as a resource to use during C++ trainings. If you're curious about how it came
to be, take a look at [about.md](about.md).

## Getting started

### Linux
Expand Down
113 changes: 113 additions & 0 deletions about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Exercises for the masses

## History

Working in C++ around the year 2010 was very exciting. The language was about
to receive some vast new impulses, promising better semantics, performance, …

In 2016, I was lucky enough to work in an environment that lived on the edge:
constantly following the latest (Microsoft) compiler versions, and writing C++
programs according to the latest and greatest idioms.

All of this happiness had to be shared. That’s why my employer, Sioux Embedded
Systems, asked if anyone would be able to create a C++11/14 ramp-up course for
my colleagues. Of course I bit.

The budget: 5 days of preparation - a challenge for me. It seemed a vast
undertaking, given the fact that I hadn’t been giving training, nothing ‘free’
could be found. So I decided I would borrow free and open source presentations,
and create exercises myself. But how?

As it happened, there also was a gap in the knowledge of unit testing
frameworks. So why not kill two birds with one stone? Fond of TDD, I had grown
quite familiar with the googletest framework. So I decided to create a bunch of
failing unit tests that had to be ‘fixed’ using C++11/14 features.

Since I was to take all my course material from the internet, I thought it only
fitting to give back. So I started creating the course in the open on
https://github.com/xtofl/cpp11training/.

## Overview

### Repo structure

* Presentations are stored in the `slides/` directory. There's also a
[readme](slides/README.md) to explain its contents.
* Exercises are stored per topic under the `src/` folder; within each topic,
exercise source files are numbered.
* Each topic file contains a number of `TEST` cases. Each of these cases represents
an exercise. In the comments, I try to explain what you're supposed to do (TODO),
what you're supposed to learn from this exercise (GOAL), and may add some HINTs.

### Exercise Example

For instance, one of the first exercises you'll encounter is about using the
range-based-for feature introduced in C++11.

```c++
TEST(range_based_for, DISABLED_we_can_iterate_over_a_collection)
{
int result = 0;
// TODO: extend the Range class so that it acts as a
// real 'range' and can be used in a range based for loop.
//
// GOAL: understand the working of range-based for loop, and
// adapt existing classes to it
//
// HINT: This is a harder problem: you need to provide
// a free begin(const Range&) and end(const Range&) function
// that returns an iterator-like object.
//
#ifdef solv
for (const auto &element : Range{ 1, 11 })
{
result += element;
}
#endif
EXPECT_EQ(55, result);
}
```
As you'll see, the test will
be compiled, but the `DISABLED_` prefix in its name will prevent gtest from
executing it. Removing the prefix 'activates' the test and makes it run,
but fail:
![failing-test.png](failing-test.png)
Another example: one to learn using the `transform` algorithm:
```c++
TEST(apply_transform, DISABLED_join_two_input_ranges)
{
const std::vector<std::string> keys{ {"two", "five", "ten", "forty"} };
const std::vector<int> values{ {2, 5, 10, 40} };
std::vector<std::string> numbers;
// TODO: transform keys and values into
// this python-key-value syntax
// GOAL: see that `transform` can accept two ranges
// and 'zip' them together
ASSERT_EQ(keys.size(), numbers.size());
EXPECT_EQ("two: 2", numbers[0]);
EXPECT_EQ("five: 5", numbers[1]);
EXPECT_EQ("ten: 10", numbers[2]);
EXPECT_EQ("forty: 40", numbers[3]);
}
```

## Future

Meanwhile we're 2020, and I have given this training about 5 times. Everytime,
the overall response is positive about offering running code in the form of
isolated unit tests. The fun part for me is that whenever someone finds a
mistake, I can kindly ask them to fix it and create a merge request.

And it has proven to be needed. What is also needed: some of the exercises are
a little 'far fetched', and may be replaced by more down to earth subjects.
Although on every occasion I am able to improve the guidelines, add some
exercises and the lot, this body of exercises still needs a lot of guidance.

I'm hoping that some day, this effort will be picked up and improved by 'the
masses'. For I'm convinced that good and affordable programming education is
an important ingredient for an inclusive world.
Binary file added failing-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d37c367

Please sign in to comment.