What does it mean when code is “easy to reason about”?
Preethi Kasireddy

I’d like to add a few more points about “easy to reason” functions from Robert C. Martin’s book, Clean Code.

According to Martin, functions should…

  • do only one thing (error handling, conditional checks, and loops are one thing)
  • hardly ever be more than 20 lines long
  • contain one level of abstraction
  • use descriptive names and have consistant naming schemes
  • ideally have zero arguments, followed by one, then occasionally two and hardly ever three
  • avoid flag input arguments and output arguments
  • either do something or answer something, but not both
  • avoid duplicating code

The whole book, for me, was a good read.

Like what you read? Give James T. a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.