Code Standards And Practices Level 1 Practice Test

Access More Questions
Why should comments align with code rather than duplicating logic?
Correct Answer:
They should describe intent and decisions, not exactly replicate code behavior.
Explanation:
Comments should describe why something exists and what decisions shaped it, not reproduce exact code behavior. They explain the intent, the problem being solved, and any trade-offs or constraints, so future readers understand the purpose behind the implementation even if the code changes later. Duplicating logic in comments creates maintenance trouble: when the code evolves, those comments can become out of sync and misleading, forcing you to chase discrepancies. Inline notes about intent stay close to the relevant code, guiding readers without cluttering the actual logic. External documentation has a role, but it’s easy to miss the immediate context near the code if you rely only on it. And because intent and decisions aren’t always obvious from code alone, comments that capture the rationale help explain why a particular approach was chosen.

Access more questions from this quiz

Continue to Code Standards and Practices Level 1 Practice Test for more practice questions and the full quiz experience.

Access More Questions