Refactoring tip: no empty lines inside a function

InstructorAndré Staltz

Share this video with your friends

Send Tweet

To keep code elegant and readable, this lesson presents a refactoring technique consisting of two rules: (1) Don't have empty lines in a function, (2) keep the function short, with at most 6 or 8 statements. See how this can help keep each function focused on one responsibility.

Free Community Resource

A Community Resource means that it’s free to access for all. The instructor of this lesson requested it to be open to the public.

praveen
praveen
~ 5 years ago

What was the editor being used?

Maxime
Maxime
~ 5 years ago

All these small functions just add some noise to the code. They are only used in one other function. They make this function more "readable" but the global code get bloated with useless functions. It bug me less in other language where we can tag a function as private or protected.

Francis
Francis
~ 5 years ago
  • Six statements seems pretty egregious
  • You'll end up with ludicrous fn names, like animateLastPointFromLeadingLine
  • Debugging this would mean dotting the file with breakpoints, huge time waster
Vamshi
Vamshi
~ 4 years ago

For me, its too many functions already!