Skip to content

Commit 80780c5

Browse files
vulderjcvwBogCygronchaine
authored
Adds initial draft for containers topic (#91)
resolves #103 Co-authored-by: JC van Winkel <jcvw@google.com> Co-authored-by: Bogusław Cyganek <cyganek@agh.edu.pl> Co-authored-by: Jari Ronkainen <ronchaine@gmail.com>
1 parent c773633 commit 80780c5

File tree

6 files changed

+151
-0
lines changed

6 files changed

+151
-0
lines changed

sources/knowledge_areas.dat

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ EH Error Handling
5555
? ? ? ? errno
5656
? ? ? ? Error Codes
5757
eh y y y Exception Handling
58+
PD Program Design
59+
cont y y y Containers
5860
DE Debugging Errors
5961
compiletimeerr y y y Compile-Time Errors
6062
runtimeerr y y y Run-time Errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Program Design: Algorithms
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
This topic is currently under construction and will soon be filled with information :)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
## Program Design: Containers {#cont}
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
### Overview
7+
8+
_Provides a short natural language abstract of the module’s contents._
9+
_Specifies the different levels of teaching._
10+
11+
------------------------------------------------------------------------
12+
Level Objective
13+
----------------- ------------------------------------------------------
14+
Foundational Using standard containers
15+
16+
Main Extending standard containers and day-to-day usages
17+
18+
Advanced ---
19+
20+
------------------------------------------------------------------------
21+
22+
### Motivation
23+
24+
_Why is this important?_
25+
_Why do we want to learn/teach this topic?_
26+
27+
Storing data is an essential part of computations.
28+
We use abstractions to make it easier to reason about and work with the data.
29+
This leads to grouping related data variables together in data structures to give the grouping a name and to be able to make multiple instances of that data structure.
30+
Data structures are therefore foundational building blocks for program design and are present in almost every program.
31+
32+
Data structures come in many different forms, but there are special data structures that group objects of related types together.
33+
In C++ these collections of data are called containers.
34+
The C++ standard library provides a wide range of such common containers.
35+
To make algorithms more universally applicable to containers, the standard library defines a common interface.
36+
This way, containers build a bridge between algorithms and how data is organized.
37+
38+
39+
### Topic introduction
40+
41+
_Very brief introduction to the topic._
42+
43+
### Foundational: Using standard containers {#cont-found}
44+
45+
#### Background/Required Knowledge
46+
47+
A student:
48+
49+
* "for loops"
50+
* "defining variables"
51+
* "main function"
52+
53+
#### Student outcomes
54+
55+
_A list of things "a student should be able to" after the curriculum._
56+
_The next word should be an action word and testable in an exam._
57+
_Max 5 items._
58+
59+
A student should be able to:
60+
61+
1. setup and add objects to a container
62+
2. work with objects that are stored in a container
63+
64+
#### Caveats
65+
66+
_This section mentions subtle points to understand, like anything resulting in
67+
implementation-defined, unspecified, or undefined behavior._
68+
69+
* On a foundational level, avoid using iterators when teaching containers to prevent problems, such as iterator invalidation or dangling iterators.
70+
* Avoid going deep into the template notation
71+
* Teach people to not use `vector<bool>`
72+
73+
#### Points to cover
74+
75+
_This section lists important details for each point._
76+
77+
* Creating containers, adding objects, iterating over them using range based or index based for loops.
78+
* `vector`, `string`, `unordered_map`, `unordered_set`
79+
* Notation for having container of different value types with angle brackets
80+
81+
82+
### Main: Extending standard containers and day-to-day usages {#cont-main}
83+
84+
#### Background/Required Knowledge
85+
86+
* Basic understanding of standard algorithms [[Program Design: Algorithms - Foundational]][1]
87+
* Basic understanding of classes and class templates [[User-defined Types: Class Templates - Foundational]][2]
88+
89+
#### Student outcomes
90+
91+
A student should be able to:
92+
93+
1. make effective use of the standard containers.
94+
2. make use of iterators to iterate over a sequence and call algorithms.
95+
3. make a proper choice what container to use based on its characteristics.
96+
4. write a container class template for a specific need (based on a standard container).
97+
5. make use of common container idioms.
98+
99+
#### Caveats
100+
101+
* Iterator invalidation
102+
* When extending standard containers, prefer delegation over inheritance
103+
104+
#### Points to cover
105+
106+
* Alternative ways of iterating over a container using iterators
107+
* Adapting or extending standard containers (e.g., writing wrapper types with additional semantics)
108+
* Discuss the different characteristics and trade-offs of standard containers
109+
* Common idioms (e.g., find-erase)
110+
* Usage of end-of-sequence iterators [[Program Design: Iterators - Foundational]][3]
111+
* [Optional] Using containers together with ranges [[Program Design: Ranges - Foundational]][4]
112+
113+
114+
### Advanced
115+
116+
_These are important topics that are not expected to be covered but provide
117+
guidance where one can continue to investigate this topic in more depth._
118+
119+
* creating your own STL compatible containers from the ground up
120+
* using containers with non-default allocators
121+
122+
[1]: ../program-design/algorithms.md
123+
[2]: ../user-defined-types/class-templates.md
124+
[3]: ../program-design/iterators.md
125+
[4]: ../program-design/ranges.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Program Design: Iterators
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
This topic is currently under construction and will soon be filled with information :)
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Program Design: Ranges
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
This topic is currently under construction and will soon be filled with information :)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## User-defined Types: Class Templates
2+
3+
_Skeleton descriptions are typeset in italic text,_
4+
_so please don't remove these descriptions when editing the topic._
5+
6+
This topic is currently under construction and will soon be filled with information :)

0 commit comments

Comments
 (0)