Clear Code: How To Write Code That Is Easy To Read

This article is a follow up to a tweet I made on how I deal with my poor ability to remember implementation (code). It may seem funny to you, but I do actually tend to forget what I write shortly after writing it.

First, we will discuss why you may want to write more legible code as opposed to concise (short) code. Afterwards, we will look at the following strategies on how to do that with:

  • Variable, class, and function naming
  • Helper functions
  • Code comments
  • Enums/Dictionaries/Sealed Classes/Etc.
  • Package organization and naming

Stock image of someone reading.

Does Efficiency Come From Fewer Keystrokes?

I recall as a junior developer, thinking that short or abbreviated names for identifiers (basically any code construct us developers are allowed to name) were more efficient.

My logic was simple: If it takes me less time to write it, then I can get the job done faster.

Website

Tags: Code Read