From the course: Agile Software Development: Clean Coding Practices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Prefer clarity over brevity

Prefer clarity over brevity

From the course: Agile Software Development: Clean Coding Practices

Start my 1-month free trial

Prefer clarity over brevity

- [Narrator] When writing code, it can be tempting to name things in a very short and terse way. It's fewer characters that you have to type and the computer is able to understand your meaning just fine. But the primary audience for the code that we write is that they're humans. So we need to make sure we're putting a preference on putting names that are clear. Clear names are better than brief ones. A frequent place where overly brief names are found is in code that loops over an array. Let's take a peak at this loop. This loop is using i as the value that's used to index into the fruits array. In a file this short, it's not a big issue. It only takes a few seconds for the reader to understand what's going on. But why are we making the reader take those few extra seconds to understand our intent? Also, take note of the variable that's used to store the array value for each loop iteration. We can make an educated…

Contents