CS111: Documentation - Code Comments
Strategic inline comments explaining game logic
Documentation: Code Comments
Objective
Students must write strategic inline comments explaining complex game logic and design decisions.
Evidence
Code comments in game components:
- DeathBarrier.js - Debug comments explaining collision logic
- Ghost.js - Comments explaining pathfinding logic
- Multiple classes - Logic explanation comments
Implementation Details
- Single-line comments with //
- Multi-line comments with /* */
- Comments explaining “why” not “what”
- Comments for complex algorithms
- TODOs and FIXMEs for future work
Best Practices
- Comment density: 10-20% of code
- Explain non-obvious logic
- Avoid redundant comments
- Keep comments updated with code
- Use comments to highlight edge cases
Key Concepts
- Comment types: single-line, multi-line
- Comment content: explaining intent and logic
- Differentiating comments from documentation
- Maintenance and keeping comments current