# 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… **Computer Science** | **Grade 9** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g9-cs-readable-code.html* 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. **Copy link** works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment. ## 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. Why does it matter HOW your code looks, not just that it works? ## Readable, or Messy? Project this and sort each habit into Readable or Messy. ## 55 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — Code Is Read 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. ### Use — Readable Code Students learn. #### 👩‍🏫 Teacher Moves - Send students to Readable or Messy? - Sort each habit. - Note names & comments. #### 🎒 Student Actions - Sort. - Say. - Note it. ### Modify — Clean It Students practice. #### 👩‍🏫 Teacher Moves - Rename a vague variable. - Add a comment. - Fix the indentation. #### 🎒 Student Actions - Rename. - Comment. - Indent. ### Create — Create Students apply. #### 👩‍🏫 Teacher Moves - Clean up a messy snippet. - Add clear names. - Split into a function. #### 🎒 Student Actions - Clean. - Name. - Split. ### Reflect — Reflect 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. ## Built to the standards you report on Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students. Create readable, documented programs. Refine code for clarity. Document code for others. Communicate clearly through artifacts. ## One lesson, every learner ### Multilingual Learners - Readable/messy code cards. - Frame: "a clear name is ___." - Compare two snippets. ### Support & Access - Sort readable vs messy only. - Use 4 habits. - Use clear examples. ### Stretch & Extend - Write a style guide. - Refactor a program. - Peer-review for readability. ### What to gather - 📽️Screen / board - ✨Code-habit cards - 💻Readable or Messy? - 📄Messy snippet - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **readable code**: code that is easy to understand - **variable name**: what you call a value - **comment**: a note in code for humans - **indentation**: spacing that shows structure - **function**: a named reusable block - **refactor**: clean up without changing behavior - **convention**: an agreed style - **maintainable**: easy to update later ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: writing readable code. Have students clean up a messy code snippet. A printable snippet sheet is in the CS library. ## Check your understanding **1. What does “readable code” mean?** - a named reusable block - easy to update later - what you call a value - code that is easy to understand *(correct)* “readable code” means: code that is easy to understand **2. Which word means: “what you call a value”?** - readable code - variable name *(correct)* - convention - function “variable name” means: what you call a value **3. What does “comment” mean?** - code that is easy to understand - an agreed style - a named reusable block - a note in code for humans *(correct)* “comment” means: a note in code for humans **4. Which word means: “spacing that shows structure”?** - indentation *(correct)* - readable code - refactor - comment “indentation” means: spacing that shows structure **5. What does “function” mean?** - a named reusable block *(correct)* - what you call a value - an agreed style - easy to update later “function” means: a named reusable block **6. Which word means: “clean up without changing behavior”?** - convention - readable code - indentation - refactor *(correct)* “refactor” means: clean up without changing behavior ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g9-cs-readable-code.html All lessons: https://lessonplans.k12academics.com/