Code Smell 74 — Empty Lines

Breaking the code to favor readability asks for refactor.

Maximiliano Contieri
Dev Genius

--

Photo by Sigmund on Unsplash

TL;DR Don’t add empty lines to your methods. Extract them!

Problems

  • Readability
  • Kiss
  • Low Reuse

Solutions

1. Extract Method

2. Refactor

3. Remove unneeded lines.

Sample Code

Wrong

Right

Detection

This is a policy smell. Every linter can detect blank lines and warn us.

Tags

  • Readability
  • Long Methods

Conclusion

Empty lines are harmless, but show us an opportunity to break the code into small steps.

If you break your code with comments, it is also a code smell asking for a refactor.

Relations

It’s OK to figure out murder mysteries, but you shouldn’t need to figure out code. You should be able to read it.

Steve McConnell

--

--

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com