Documentation Examples in CS Thinking
Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Documentation.
This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.
Concept Recap
Software documentation is the collection of written descriptions that explain how a system works and how to use it, including inline code comments, user guides, API references, design documents, and README files. Good documentation makes software understandable, usable, and maintainable by both current and future developers.
Documentation is a letter to your future self (and teammates) explaining what the code does and why you made certain decisions.
Read the full concept explanation โHow to Use These Examples
- Read the first worked example with the solution open so the structure is clear.
- Try the practice problems before revealing each solution.
- Use the related concepts and background knowledge badges if you feel stuck.
What to Focus On
Core idea: Code tells the computer what to do. Documentation tells humans why the code exists and how to use it.
Common stuck point: Don't document what the code does (the code itself says that). Document why it does it โ the reasoning and decisions.
Sense of Study hint: When writing documentation, first explain the purpose (why does this code/module exist?). Then describe the interface (what inputs does it take and what does it return?). Finally, include usage examples that show the most common use cases in action.
Worked Examples
Example 1
easyAnswer
First step
Full solution
- 2 Step 2: // Calculate the sum of numbers 1 to 10. SET total = 0 // Initialise accumulator. FOR i = 1 TO 10: total = total + i // Add each number to running total. OUTPUT total // Display the result (should be 55).
- 3 Step 3: Good comments explain WHY, not just WHAT. 'Add i to total' is a bad comment (restates the code). 'Accumulate sum for average calculation' is a good comment (explains purpose).
Example 2
mediumExample 3
mediumExample 4
mediumExample 5
mediumExample 6
hardExample 7
hardExample 8
hardExample 9
hardExample 10
challengePractice Problems
Try these problems on your own first, then open the solution to compare your method.
Example 1
mediumExample 2
hardExample 3
easyExample 4
easyExample 5
easyExample 6
easyExample 7
easyExample 8
easyExample 9
easyExample 10
easyExample 11
mediumExample 12
mediumExample 13
mediumExample 14
mediumExample 15
mediumExample 16
mediumExample 17
mediumExample 18
mediumExample 19
mediumExample 20
challengeExample 21
challengeExample 22
challengeExample 23
easyExample 24
easyExample 25
easyExample 26
mediumExample 27
mediumExample 28
mediumExample 29
mediumExample 30
mediumExample 31
hardExample 32
hardExample 33
hardRelated Concepts
Background Knowledge
These ideas may be useful before you work through the harder examples.