Practice Documentation in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick 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.
Example 1
easyWhy are comments important in code? Add appropriate comments to this pseudocode: SET total = 0. FOR i = 1 TO 10: total = total + i. OUTPUT total.
Example 2
mediumList three types of software documentation and explain who each is written for.
Example 3
mediumA function has no comments or documentation. Reverse-engineer its purpose from the code: FUNCTION mystery(text): SET result = ''. FOR i = LENGTH(text)-1 TO 0 STEP -1: result = result + text[i]. RETURN result. Write appropriate documentation for it.
Example 4
hardArgue for and against the statement: 'Good code is self-documenting and does not need comments.' When are comments essential despite good naming?