“Programs are meant to be read by humans and only incidentally for computers to execute”

— Donald Knuth

  • Write intent revealing names. If the variable stores the last updated record, name it ‘lastUpdatedRecord’, not just ‘record’, or even ‘lastRecord’
  • Make clear distinctions. What kind of info will ‘ProductInfo’ has that the ‘ProductData’ won’t?
  • Add context to names. Put variable state in well-named classes.
  • Don’t abbreviate. Say ‘getWindow’ not ‘getWin’
  • Pick one word per abstract concept & stick with it. What’s the difference between fetch and retrieve? pick and use only one
  • Don’t pun, don’t make your readers mentally map names to something else.
  • Use conventions for common operations.
  • Avoid similar sounding & easily misspelled names
  • Favor readability over brevity

Full post here, 7 mins read