Home›Lesson Plans›Computer Science›Algorithms & Programming · Grade 8

Code Comments

Eighth graders learn that the best programmers write for people as well as computers, using comments to explain their code so others, and their future selves, can understand it, then check what they know.

Grade 8Code Comments50 minutes1 class periodCSTA / ISTEExplicit teaching4 StandardsCSTA
Start the Lesson
Assign or share this lesson

Copy link works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment.

Lesson at a Glance

Everything you need before the bell rings

Learning Objectives

Students will be able to…

  • ✓Know what a comment is.
  • ✓See the computer ignores it.
  • ✓Write useful comments.
  • ✓Check what you know.
Essential Question

You open code you wrote months ago and cannot remember how it works, and a short note in the code could have saved you. What are comments, and why do programmers write them?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Comments Check · Interactive

Comments Check

Project this and answer each question about comments and how they make code easier to understand — read the explanation after each one.

💬 Check what you know about code commentsTry it
Answer each question about comments and how they make code easier to understand.
The Lesson · Explicit teaching

50 minutes, five moves

Tap any phase to open the teacher moves and student actions.

1

Hook — Notes for Humans

5 min

You open code you wrote months ago and cannot remember how it works. A short note left in the code could have saved you. What are comments, and why do programmers write them?

👩‍🏫 Teacher Moves

  • Show code with and without comments.
  • Ask which is clearer.
  • Set the goal.

🎒 Student Actions

  • Think.
  • Share.
  • Get ready.
2

Use — Comments Check

12 min

Students answer questions about comments.

👩‍🏫 Teacher Moves

  • Send students to the Comments Check.
  • Answer each question.
  • Read the why.

🎒 Student Actions

  • Answer.
  • Check.
  • Read it.
3

Modify — Comment the Code

13 min

Students add a helpful comment.

👩‍🏫 Teacher Moves

  • Read a line of code.
  • Write a comment for it.
  • Say what it explains.

🎒 Student Actions

  • Read.
  • Write.
  • Say.
4

Create — My Commented Program

15 min

Students comment a short program.

👩‍🏫 Teacher Moves

  • Take a short program.
  • Add a comment at the top.
  • Explain the tricky parts.

🎒 Student Actions

  • Take.
  • Add.
  • Explain.
5

Reflect — Writing for People

5 min

Students reflect on comments.

👩‍🏫 Teacher Moves

  • Does the computer run your comments?
  • What makes a comment helpful?
  • Complete the exit ticket.

🎒 Student Actions

  • Say it.
  • Say it.
  • Complete the exit ticket.
Standards Alignment

Built to the standards you report on

Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students.

CSTA
2-AP-15

Document a program with comments to make it easier to follow.

CSTA
2-AP-17

Systematically improve and maintain programs for others to use.

CSTA
2-AP-19

Describe how documentation helps people work together on code.

ISTE
1.5.c

Computational Thinker: create and document clear, reusable solutions.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Code snippet cards.
  • Sentence frame: “This comment explains ___ .”
  • Answer one question at a time.

Support & Access

IEP / 504
  • Start with what a comment is.
  • Add one comment together.
  • Review one idea at a time.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Rewrite a weak comment into a useful one.
  • Comment a short program fully.
  • Explain when a comment is not needed.
Materials

What to gather

  • 📽️Projector / board
  • 🖼️Code snippet cards
  • 💻Comments Check
  • 💻A short sample program
  • ✏️Pencils
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

commenta note in code for people, ignored by the computercodethe instructions that make up a programdocumentationnotes that explain how a program worksreadableeasy for a person to understandmaintainto keep code working and up to date over timesyntaxthe symbols that mark a comment in a languagecollaborateto work together on the same codecluttertoo much that gets in the way of reading
Evaluate

Exit Ticket

Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students.

QUESTION 1
Does the computer run your comments?
No. Comments are notes for people; the computer ignores them when the program runs.
QUESTION 2
What makes a comment helpful?
It explains why the code does something or clears up a tricky part, instead of just repeating what each line obviously says.
QUESTION 3
Why do comments help a team of programmers?
They let everyone understand and build on each other's code quickly.

Create: my commented program.

Have students take a short program, add a comment at the top, and explain the tricky parts, so writing for people becomes part of coding. A printable code-comments worksheet is in the Computer Science library.

Study · Flashcards

Study the key terms

Tap a card to flip it, then rate whether you knew it. Built from this lesson’s vocabulary.

🃏 Code CommentsFlip
Card 1
Term
Tap to flip →
Meaning
0

Nice work!

Practice · Quiz

Check your understanding

A quick self-check with instant feedback, drawn from this lesson’s key terms.

📝 Code CommentsQuiz
Score: 0
1 / 6
Question 1
0%

Nice work!

Practice · Worksheet

Printable worksheet

A print-and-go review sheet with a built-in answer key. Tap “Show answer key” to reveal answers, or print the clean version for students.

🖨️ Code CommentsPrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: clutter, code, collaborate, comment, documentation, maintain, readable, syntax
  1. easy for a person to understand
  2. to keep code working and up to date over time
  3. to work together on the same code
  4. too much that gets in the way of reading
  5. notes that explain how a program works
  6. the symbols that mark a comment in a language
  7. a note in code for people, ignored by the computer
  8. the instructions that make up a program

Part B · Show what you learned

  1. Does the computer run your comments?
  2. What makes a comment helpful?
  3. Why do comments help a team of programmers?
Answer key — Part A: 1) readable · 2) maintain · 3) collaborate · 4) clutter · 5) documentation · 6) syntax · 7) comment · 8) code
Part B: 1) No. Comments are notes for people; the computer ignores them when the program runs. 2) It explains why the code does something or clears up a tricky part, instead of just repeating what each line obviously says. 3) They let everyone understand and build on each other's code quickly.