Home›Lesson Plans›Computer Science›Programming · Grade 9

Writing Readable Code

Ninth graders learn that code is read far more often than it is written — by teammates and by future-you. Clear names, comments, consistent indentation, and functions make code readable and maintainable. They sort good habits from messy ones, then clean up a snippet.

Grade 9Writing Readable Code55 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…

  • ✓Use clear names.
  • ✓Add useful comments.
  • ✓Indent & structure.
  • ✓Clean up code.
Essential Question

Why does it matter HOW your code looks, not just that it works?

0
Lesson Phases
0
Vocabulary Terms
0
Standards Aligned
0
Interactive Task
Sort It · Interactive

Readable, or Messy?

Project this and sort each habit into Readable or Messy.

✨ Sort each — makes code readable, or messy?Try it
✨ Readable
👎 Messy
Tap one, then tap a box.
The Lesson · Explicit teaching

55 minutes, five moves

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

1

Hook — Code Is Read

6 min

Who reads your code weeks later — and can they understand it?

👩‍🏫 Teacher Moves

  • Pose the question.
  • Share ideas.
  • Set the goal.

🎒 Student Actions

  • Think.
  • Share.
  • Get ready.
2

Use — Readable Code

13 min

Students learn.

👩‍🏫 Teacher Moves

  • Send students to Readable or Messy?
  • Sort each habit.
  • Note names & comments.

🎒 Student Actions

  • Sort.
  • Say.
  • Note it.
3

Modify — Clean It

14 min

Students practice.

👩‍🏫 Teacher Moves

  • Rename a vague variable.
  • Add a comment.
  • Fix the indentation.

🎒 Student Actions

  • Rename.
  • Comment.
  • Indent.
4

Create — Create

15 min

Students apply.

👩‍🏫 Teacher Moves

  • Clean up a messy snippet.
  • Add clear names.
  • Split into a function.

🎒 Student Actions

  • Clean.
  • Name.
  • Split.
5

Reflect — Reflect

7 min

Students close.

👩‍🏫 Teacher Moves

  • Name a readable-code habit.
  • Name a messy one.
  • Complete the exit ticket.

🎒 Student Actions

  • Name one.
  • Name one.
  • 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
3A-AP-18

Create readable, documented programs.

CSTA
3A-AP-17

Refine code for clarity.

CSTA
3A-AP-23

Document code for others.

ISTE
6

Communicate clearly through artifacts.

Differentiation

One lesson, every learner

Multilingual Learners

ELL / EMERGING READERS
  • Readable/messy code cards.
  • Frame: "a clear name is ___."
  • Compare two snippets.

Support & Access

IEP / 504
  • Sort readable vs messy only.
  • Use 4 habits.
  • Use clear examples.

Stretch & Extend

GIFTED / EARLY FINISHERS
  • Write a style guide.
  • Refactor a program.
  • Peer-review for readability.
Materials

What to gather

  • 📽️Screen / board
  • ✨Code-habit cards
  • 💻Readable or Messy?
  • 📄Messy snippet
  • 📓Notebooks
  • 🎫Exit-ticket slips
Vocabulary

Key terms — hover for a quick definition

readable codecode that is easy to understandvariable namewhat you call a valuecommenta note in code for humansindentationspacing that shows structurefunctiona named reusable blockrefactorclean up without changing behaviorconventionan agreed stylemaintainableeasy to update later
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
Name a habit that makes code readable.
Clear names, comments, consistent indentation, or functions.
QUESTION 2
Name a messy habit.
Vague names, no comments, or random indentation.
QUESTION 3
Why does readability matter?
Code is read far more often than written — by others and future-you.

Reflect: writing readable code.

Have students clean up a messy code snippet. A printable snippet sheet is in the CS 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.

🃏 Writing Readable CodeFlip
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.

📝 Writing Readable CodeQuiz
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.

🖨️ Writing Readable CodePrint
Name: ________________________
Date: ____________

Part A · Write the word that matches each meaning

Word bank: comment, convention, function, indentation, maintainable, readable code, refactor, variable name
  1. an agreed style
  2. easy to update later
  3. a note in code for humans
  4. code that is easy to understand
  5. what you call a value
  6. clean up without changing behavior
  7. a named reusable block
  8. spacing that shows structure

Part B · Show what you learned

  1. Name a habit that makes code readable.
  2. Name a messy habit.
  3. Why does readability matter?
Answer key — Part A: 1) convention · 2) maintainable · 3) comment · 4) readable code · 5) variable name · 6) refactor · 7) function · 8) indentation
Part B: 1) Clear names, comments, consistent indentation, or functions. 2) Vague names, no comments, or random indentation. 3) Code is read far more often than written — by others and future-you.