The running project

The field-sensor station

A small weather station on a pole in a field logs temperature, humidity, pressure and wind once a minute. Across the semester you build its software: a math library in C, a sensor database, a C++ class hierarchy, an image tool for its sky camera and a search study over a million readings.

struct readingsensor_id 1001time_s 60value 21.75 °Cflags 0x03 VALID | CALIBRATEDCSV: 1001,60,21.75,3

Most chapters return to one running project: software for a small weather station on a pole in a field, whose logger records temperature, humidity, pressure and wind once a minute. Six programming assignments carry it (Table H.1; Appendix G has more detail).

G.1 Labs

Every chapter has one lab, in its Section N.5 (Chapter 2's is unnumbered). Each lab states a question, asks for a prediction before any agent session, and names the programming assignment it advances.

Table G.1. Labs by chapter.

Chapter Lab PA Phase
1 Read the error, fix it by hand None Tutor
2 Watch a loop, then run two steps None Tutor
3 Count Before You Trust PA1 (multiplication count for stn_ipow) Tutor
4 Check the tutor's trace in gdb PA1 (stn_sqrt, stn_mean_sd by hand) Tutor
5 n, n², n³, and PA1 on the edges PA1 (completes) Tutor
6 The agent says "no leaks"; Valgrind decides PA2 (a test for every -1 return) Tutor
7 Split the station database PA2 (headers, stubs, makefile) Tutor
8 PA2, list and vector, under a timing test PA2 (completes) Tutor
9 The station reads its log None (PA3 reads through stn_log) Tutor
10 Quadratic to linear, then PA3 PA3 (first milestones) Pair
11 The station's upload queue None (spec format for later PAs) Pair
12 Port it, then list what survived PA4 (part 1) Pair
13 The Image fence PA4 Pair
14 A rule-of-five audit of an agent-written class PA4 (completes) Pair
15 PA5, the simulated station PA5 Pair
16 Per-sensor statistics with containers you chose PA6 (begins) Team
17 Sensor index timing study PA6 (the BST column) Team
18 The PA6 search study PA6 (completes) Team
19 The alerts module Final feature Team
20 The shared ring buffer None (optional chapter) Team

G.2 Programming assignments

Every PA ends in an Audit Report (Appendix A), work-log rows (Appendix E) and an oral defense (Appendix F). Each is graded on hidden tests, sanitizer-clean runs, the Audit Report and the specification, not on code that merely runs.

Table G.2. The six programming assignments.

PA Released What it builds Main trap Instrument that proves it
PA1 Math library Ch 3 (due Ch 5) stn_math by hand: stn_ipow, stn_factorial, stn_gcd, stn_sqrt, stn_mean_sd, stn_dew_point; an agent version for comparison only Happy-path numerics: no iteration cap, overflow checked after the multiply, NaN and n = 0 unhandled Edge tests under timeout 3; UBSan; a rerun at -O2
PA2 List and vector Ch 6 (due Ch 8) rvec and rlist of readings, by hand, one interface style Growth by +1; old buffers leaked Hidden test of 1,000,000 appends with a capacity-change count, under the sanitizer build; Valgrind
PA3 Sorting Ch 10 Insertion sort by hand; merge sort and quicksort delegated to the Pair from your spec First-element pivot on sorted input; leaked merge temporaries; unstable where stable was specified Hostile inputs at scale; LeakSanitizer at n = 0, 1; the stability test
PA4 Image processing Ch 12 (due Ch 14) C station tools ported to C++; stn::Image with box blur, edge energy and seam carving C habits in the port; exponential recursion where dynamic programming belongs Habit scan and diff against golden output; call counts and timing at increasing heights
PA5 OOP simulation Ch 15 Sensor hierarchy, Station owning sensors through unique_ptr, simulated time steps Missing virtual destructor; slicing; inheritance where composition fits ASan test that destroys a full station; deleted base copy; Table 15.1
PA6 Search study Ch 16 (due Ch 18) Lookup by sensor ID across 10³ to 10⁶ records: linear scan, binary search, BST, hash table; timing plots and a written comparison Unbalanced trees on sorted input; weak hash functions; timing claims without measurements Log-log slopes from the frozen harness; bucket histogram; sorted-input BST row

The PA1 and PA2 interfaces are fixed, so that every chapter that uses them agrees. PA1 functions return a status (0 success, −1 bad input, −2 non-convergence or overflow) and deliver results through out-parameters (Chapter 4). PA2's _new returns an owned object or NULL, _free accepts NULL, failing operations return −1 and change nothing, readings are copied in, and _get returns a borrowed pointer, which for rvec is valid only until the next push or free (Chapter 6). PA3's status codes extend PA1's: −2 there means the temporary could not be allocated (Section 10.4).

The capstone final feature (Chapter 19) is the station's alerts module, built by an agent team: a frost warning when temperature falls below 2 °C with humidity over 90% at the same minute, and a sensor-fault alert when a sensor reports OUT_OF_RANGE three times in ten minutes.

G.3 The 15-week schedule

Table G.3. A 15-week schedule (as in How to Use This Book).

Week Chapters Phase Assignments
1 1, 2 Tutor AI policy signed; work log starts
2 to 4 3, 4, 5 Tutor PA1 (weeks 2 to 4)
5 to 6 6, 7, 8, 9 (part 1) Tutor PA2 (weeks 5 to 6)
7 to 8 10, 11, 9 (part 2) Pair (9 stays Tutor) PA3 (week 7)
9 to 12 12, 13, 14, 15 Pair PA4 (weeks 9 to 11); PA5 (week 12)
13 to 15 16, 17, 18; 19 Team PA6 (weeks 13 to 15); final feature

Chapter 9 is read in two parts, in weeks 6 and 8. Chapter 19, the capstone, runs alongside the last weeks or in the exam period.

G.4 Placing Chapter 20

Chapter 20 is optional. It assumes Chapters 14 and 16 are done: std::lock_guard is RAII (Chapter 14), and the chapter uses lambdas and the Team-phase roles (Chapter 16). How to Use This Book names three placements; the details in Table G.4 are suggestions for the instructor to adapt.

Table G.4. Three ways to place Chapter 20.

Option When What changes
A. Closing chapter In place of Chapter 19, in the capstone weeks The shared ring buffer lab is the final feature and is defended in the final oral defense
B. Extension reading After Chapter 19, or alongside it No graded lab; students may run the lab for practice, with TSan output in any Audit Report that claims "no race"
C. Two-week module Any two weeks once Chapters 14 and 16 are done Week one: Sections 20.1 and 20.2 with the counter experiment; week two: Sections 20.3 to 20.5 and the lab; the instructor shortens or moves other work to make room

Whichever option you choose, keep the chapter's rule from the first day it is taught: a "no race" claim must cite TSan output from a stress test, not a pass count.