-
Notifications
You must be signed in to change notification settings - Fork 907
Open
Description
"always return a function's value as early as possible"
I think you should put some caveats on this. Returns (and breaks and other break out statements) buried inside blocks of code are easily missed and are a very significant source of bugs on later modifications to the code (I speak with many years of experience).
For me returns should either be in the first few lines of the function (where some simple ifs deal with trivial cases) or in the last few lines of a function.
If one has to put a return in the middle of a longer function then I would make it stand out with a comment so it is not easily overlooked.
return; // ****************** RETURN *********************
krystianity, user9713 and vdhuyme
Metadata
Metadata
Assignees
Labels
No labels