Skip to content

Latest commit

 

History

History
48 lines (28 loc) · 2.49 KB

writing-readable-code.md

File metadata and controls

48 lines (28 loc) · 2.49 KB

Writing Readable Code

Motivation

  • As a software engineer, you'll work in teams where writing clear, readable code is crucial for collaboration.
  • Writing clear, readable code saves time and helps everyone, whether you're revisiting your own work later or another engineer is updating it.

Looking at an example

  • Professional engineers tend to write readable code more often than not. An example is css-tricks, a popular site that teaches various skills relating to Front-end development. There are various code snippets available on the site and these code snippets are written in a manner that makes then easily readable. For example, this page on HTML form markups which makes it easy to understand the role of various elements being used.

Objectives

Participants will be able to:

  • Refactor a provided code sample to make it more readable

Specific Things to Learn

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

Lesson

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

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

  2. Using Replit 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.

Supplemental Materials

Check for Understanding

  • Why is it important to write readable code?
  • How do you make your code more readable?
  • If you want to assign your Birth Year to a variable which variable name would be more appropriate: let x or let myBirthYear.