BP18: Make code as readable as possible, not as short as possible

  • Write your code to be as readable as possible.
  • It doesn't matter if the total count of lines of your code becomes higher after the refactoring. If it's for the sake of clarity, it's perfectly okay.
  • Don't be affraid to extract single line of code into a separate method. The descriptive method name works as a comment so you don' need in-line comments then.

When your coleague asks you: "So you just refactored the code to make 10 lines out of original 5 lines?"

What will you answer? You should answer "Yes. Because it's more readable this way. And atomic. And reusable".

 

Comments

Anonymous
What the f* is separate method?

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play