Skip to content

Latest commit

 

History

History
58 lines (34 loc) · 2.48 KB

writing-readable-code.md

File metadata and controls

58 lines (34 loc) · 2.48 KB

Writing Readable Code

Projected Time

About 90 minutes

  • 10 minutes for "Writing Readable Code" video walkthrough of slides
  • 25 minutes for "Writing Readable JavaScript" video
  • 30 minutes for Independent Practice
  • 15 minutes for Group Practice

Prerequisite

Attendance at Techtonica's HTML/CSS & JS workshops

Motivation

Since most software engineering is done in teams, it's important that the code you write is easy for others to read. You will be expected to write easily-readable code as a software engineer.

Objectives

Participants will be able to:

  • Refactor a provided code sample to make it more readable

Specific Things To Teach

  • Legibility
  • Writing descriptive, semantic variable and function names
  • Using whitespace
  • Using local variables well

Supplemental Materials

Lesson

Writing Readable Code (video walkthrough of slides)

Writing Readable Code (slides)

Common Mistakes / Misconceptions

-"As long as my code does what it's supposed to do, it's good enough." Functionality is very important, but it's only part of the bigger picture. Being able to easily maintain your code is important, too.

Independent Practice

Techtonica staff will assign #1 to half of the group and #2 to the other half of the group.

  1. Using REPL.it write a function called findMax that takes in 3 integers as parameters and returns the largest of the 3 integers.

  2. Using REPL.it write a function called bigWord that takes in a word as a string and returns True if the word has at least 10 letters and False if the word has 9 or fewer letters.

Group Practice

Pair up with a colleague who did not do the same coding challenge as you. Show your pair partner your code from the Independent Practice, but do not explain it to them. Your partner should read the code to themselves, then explain back to you their understanding of what each line of your code is doing. Listen to their feedback and suggestions — they may end up helping you to identify parts of your code that could be improved.

Check for Understanding

Engage the group in a brief roundtable discussion so they can share what improvements to their code their pair partners helped them find.