Skip to content

Commit 0bed552

Browse files
urbytes21claude
andcommitted
Add a suggested learning path through the examples
Eight stages from initialization to sockets and firmware, with the take away for each example, so the lab can be worked through in a sensible order instead of alphabetically. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LEsQ7AcLHafb1tAgosoJFz
1 parent ab82fe6 commit 0bed552

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ concurrency, sockets and embedded basics - built with CMake, GoogleTest, cppchec
55
Docker and GitHub Actions for CI/CD.
66

77
Every example lives in one file, explains itself in a header comment, and can be run on its own.
8+
New to the material? Follow the [learning path](docs/learning-path.md).
89

910
---
1011
## 1. Quick start

‎docs/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Every folder below `src/` is a group in the lab's menu. The README in each folde
44
topic, and the examples next to it show it in code. Run any example with
55
`./build/bin/cpp_lab_project --run <id>`, or browse them with the interactive menu.
66

7+
- [Learning path](learning-path.md): a suggested order through the examples
78
- [Adding examples](adding-examples.md): how the lab works and how to add your own examples
89

910
---

‎docs/learning-path.md‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# A learning path through the lab
2+
3+
The menu is organized by topic; this page suggests an order. Run an example with
4+
5+
```bash
6+
./build/bin/cpp_lab_project --run <id>
7+
```
8+
9+
and read its source next to the output - the header comment of each file says what it teaches.
10+
11+
---
12+
## Stage 1 - the language you write every day
13+
14+
| # | Example | Take away |
15+
|---|---------|-----------|
16+
| 1 | `core/basics/Initialization` | prefer `{}`; know what stays uninitialized |
17+
| 2 | `core/basics/Operations` | integer division, unsigned wrap-around, short-circuit |
18+
| 3 | `core/basics/ControlFlow` | if with initializer, range-for, why `goto` is rare |
19+
| 4 | `core/datatype/Fundamental` | sizes are minimums; use `<cstdint>` when width matters |
20+
| 5 | `core/datatype/Struct` | aggregates, designated initializers, padding |
21+
| 6 | `core/datatype/Enum` | `enum class` over plain `enum` |
22+
| 7 | `core/basics/TypeQualifier` | const vs constexpr vs consteval |
23+
24+
## Stage 2 - memory and indirection
25+
26+
| # | Example | Take away |
27+
|---|---------|-----------|
28+
| 8 | `core/datatype/Pointer` | `&`, `*`, the three const positions, pointer arithmetic |
29+
| 9 | `core/datatype/Reference` | references cannot be null or re-seated; `std::move` is a cast |
30+
| 10 | `core/datatype/Array` | arrays decay to pointers and lose their size |
31+
| 11 | `core/smart_pointer/Unique` | ownership belongs in the type system |
32+
| 12 | `core/smart_pointer/Shared` | shared ownership costs a control block |
33+
| 13 | `core/smart_pointer/Weak` | break reference cycles |
34+
35+
## Stage 3 - your own types
36+
37+
| # | Example | Take away |
38+
|---|---------|-----------|
39+
| 14 | `core/class/Encapsulation` | invariants live behind a small interface |
40+
| 15 | `core/class/Constructor` | initializer lists, delegating, explicit |
41+
| 16 | `core/class/Destructor` | destruction order and RAII |
42+
| 17 | `core/class/ShallowDeepCopying` | copying a pointer is not copying the data |
43+
| 18 | `core/class/RuleOfThreeFiveZero` | write five, or better none |
44+
| 19 | `core/class/Binding` | hiding vs overriding, virtual dispatch |
45+
| 20 | `core/class/Relationship` | composition, aggregation, association |
46+
| 21 | `core/function/operator_overloading/ArithmeticOperator` | operators behave like the built-in ones |
47+
| 22 | `core/function/operator_overloading/ComparisonOperator` | `<=>` writes the comparisons for you |
48+
49+
## Stage 4 - the standard library
50+
51+
| # | Example | Take away |
52+
|---|---------|-----------|
53+
| 23 | `core/string/StdString` | `std::string` and `std::string_view` |
54+
| 24 | `core/string/StringFormatting` | `std::format` beats streams and `printf` |
55+
| 25 | `core/container/sequence/Vector` | capacity, reallocation, invalidation |
56+
| 26 | `core/container/unordered/UnorderedMap` | `operator[]` inserts; `find`/`contains` do not |
57+
| 27 | `core/container/associative/Set` | sorted, unique, `lower_bound` |
58+
| 28 | `core/utils/Algorithm` | name the loop: algorithms and ranges |
59+
| 29 | `core/function/Lambda` | captures decide lifetime |
60+
| 30 | `core/function/Functional` | `std::function` for stored callbacks |
61+
| 31 | `core/utils/Optional` | say "no value" in the type |
62+
63+
## Stage 5 - failure, files and time
64+
65+
| # | Example | Take away |
66+
|---|---------|-----------|
67+
| 32 | `core/exception/BasicHandle` | throw by value, catch by const reference |
68+
| 33 | `core/exception/ThrowNoexcept` | `noexcept` moves make containers fast |
69+
| 34 | `core/filehandle/IOStream` | stream states and input validation |
70+
| 35 | `core/filehandle/FileIO` | text files with RAII |
71+
| 36 | `core/filehandle/Directory` | `std::filesystem` |
72+
| 37 | `core/datetime/Time` | `<chrono>` and the C time API |
73+
74+
## Stage 6 - concurrency
75+
76+
| # | Example | Take away |
77+
|---|---------|-----------|
78+
| 38 | `core/concurrency/ThreadManagement` | join or `std::jthread`, never a dangling thread |
79+
| 39 | `core/concurrency/SharingData` | arguments are copied unless you say otherwise |
80+
| 40 | `core/concurrency/RaceCondition` | see updates get lost, then fix it |
81+
| 41 | `core/concurrency/ConditionVariable` | wait with a predicate |
82+
| 42 | `core/concurrency/FuturePromise` | results and exceptions across threads |
83+
84+
## Stage 7 - design patterns
85+
86+
Start with the ones you will recognize immediately:
87+
`dp/creational/FactoryMethod`, `dp/structural/Adapter`, `dp/structural/Decorator`,
88+
`dp/behavioral/Strategy`, `dp/behavioral/Observer`, `dp/behavioral/Command`.
89+
90+
Then the rest of `dp/creational`, `dp/structural` and `dp/behavioral`. Each example first shows
91+
the problem the pattern solves; several end with the modern C++ alternative (`std::function`,
92+
`std::variant`, ranges).
93+
94+
## Stage 8 - systems and applications
95+
96+
| Example / program | Take away |
97+
|---|---|
98+
| `core/linkage/Linkage`, `core/linkage/sharing/Sharing` | what the linker sees |
99+
| `socket/simple_tcp/LoopbackEcho` | sockets end to end in one process |
100+
| `socket/simple_tcp/SimpleTCPServer` + `SimpleTCPClient` | the same across two processes |
101+
| `socket/multiple_client/MultiTCPServer` | a thread per connection |
102+
| `controller/pid/PIDSim` | a control loop |
103+
| `./build/bin/mvc_ap`, `./build/bin/mvvm_ap` | the same GUI with two architectures |
104+
| `./build/bin/demo_dlopen` | loading a plugin at run time |
105+
| `src/embedded` | a firmware image booting in QEMU |
106+
107+
---
108+
When something surprises you, change the example and rebuild - that is what the lab is for.
109+
Then write your own: see [adding-examples.md](adding-examples.md).

0 commit comments

Comments
 (0)