DEV Community

Discussion on: What makes for readable code?

Collapse
 
suvil profile image
Suvil

In addition to what everyone else has said -

  1. Smaller functions - Huge functions make things difficult to comprehend and build a mental model of.

  2. A function should do one thing and one thing only.

  3. Complex tasks should be achieved by composing together smaller functions.

  4. Smarty pants is bad - whether you are working alone or in a team. Not everyone has the same mental model for a piece of code. If you try to be excessively clever you will slow others down.

  5. Verbosity is a fine line. Don't get overly verbose with your code nor make it so short that people have to break down steps line by line.

  6. Add tools as your codebase grows. Don't start with every thing known to the ecosystem from the get go.

  7. Be cognizant that all advice (including this one) is subjective. You should evaluate your condition and strategize accordingly. Just because one big company does things one specific way, doesn't mean you should go apply it immediately to your project. I've seen plenty of startups frustrate themselves by imitating how one particular FAANG does its work.