eager_eagle ,
@eager_eagle@lemmy.world avatar

You can say any execution flow controls are like gotos - continue, break, exceptions, switch, even ifs are not much more than special cases of gotos.

This is true regardless of the size of the function which shows that the size of the function isn’t the determinant

Logical clarity does tend to worsen as the function grows. In general, it is easier to make sense of a shorter function than a longer one. I don't know how you could even say otherwise.

Early returns are still great for argument validation. The alternative means letting the function execute to the end when it shouldn't, just guarded by if conditions - and these conditions any reader would have to keep in mind.

When a reader comes across an early return, that's a state they can free from their reader memory, as any code below that would be unreachable if that condition was met.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines