# Designing Good Functions > Tenth graders learn what makes a function well-designed — it does one clear job, has a descriptive name, is short and focused, and returns useful values… **Computer Science** | **Grade 10** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-function-design.html* Tenth graders learn what makes a function well-designed — it does one clear job, has a descriptive name, is short and focused, and returns useful values. Good functions make programs easier to read, reuse, and debug. They sort good design from poor, then refactor a function. **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… - Design **one-job** functions. - Use **clear names**. - Keep them **short**. - Refactor a function. What makes a function good to use, read, and reuse? ## Good Function, or Poor? Project this and sort each into Good function design or Poor. ## 50 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — One Job A function called doEverything() — is that a good idea? #### 👩‍🏫 Teacher Moves - Pose the question. - Share ideas. - Set the goal. #### 🎒 Student Actions - Think. - Share. - Get ready. ### Use — Function Design Students learn. #### 👩‍🏫 Teacher Moves - Send students to Good Function or Poor? - Sort each one. - Note one clear job. #### 🎒 Student Actions - Sort. - Say. - Note it. ### Modify — Design It Students practice. #### 👩‍🏫 Teacher Moves - Name a function clearly. - Give it one job. - Return a value. #### 🎒 Student Actions - Name. - Focus. - Return. ### Create — Create Students apply. #### 👩‍🏫 Teacher Moves - Refactor a messy function. - Split it into smaller ones. - Name each well. #### 🎒 Student Actions - Refactor. - Split. - Name. ### Reflect — Reflect Students close. #### 👩‍🏫 Teacher Moves - Name a good-function trait. - Name a poor 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. Use modularity and well-designed functions. Document and name code clearly. Construct well-structured programs. Communicate clearly through code. ## One lesson, every learner ### Multilingual Learners - Good/poor function cards. - Frame: "a good function does ___." - Compare two functions. ### Support & Access - Sort good vs poor only. - Use 4 traits. - Use clear examples. ### Stretch & Extend - Refactor a long function. - Write a docstring. - Review a peer’s functions. ### What to gather - 📽️Screen / board - ⚙️Function cards - 💻Good Function or Poor? - 📄Messy function snippet - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **function**: a named reusable block - **one job**: a single clear purpose - **descriptive name**: a name that says what it does - **return**: send back a value - **parameter**: an input to a function - **refactor**: clean up without changing behavior - **modular**: built from small parts - **side effect**: a hidden change elsewhere ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: designing good functions. Have students refactor a messy function into smaller ones. A printable snippet sheet is in the CS library. ## Check your understanding **1. What does “function” mean?** - a hidden change elsewhere - an input to a function - a named reusable block *(correct)* - clean up without changing behavior “function” means: a named reusable block **2. Which word means: “a single clear purpose”?** - function - return - side effect - one job *(correct)* “one job” means: a single clear purpose **3. What does “descriptive name” mean?** - an input to a function - a hidden change elsewhere - built from small parts - a name that says what it does *(correct)* “descriptive name” means: a name that says what it does **4. Which word means: “send back a value”?** - one job - side effect - modular - return *(correct)* “return” means: send back a value **5. What does “parameter” mean?** - send back a value - a name that says what it does - a named reusable block - an input to a function *(correct)* “parameter” means: an input to a function **6. Which word means: “clean up without changing behavior”?** - function - modular - refactor *(correct)* - return “refactor” means: clean up without changing behavior ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g10-cs-function-design.html All lessons: https://lessonplans.k12academics.com/