Write RETURN in the end of subroutines, returning nothing

Share this topic:



Link to this posting

Postby Ursego » 21 Feb 2013, 15:34

Always end subroutines, returning nothing (like procedures in PL/SQL or void methods in C#) with return instruction.

Compilers don't force us to write return as the last statement of subroutines which return nothing, but it can be pretty useful in debugging if the last executable construction of the function enables program flow to go inside it or to jump over it (for example, if the script's LAST construction is an if, switch or a loop). If that construction is skipped by the program flow (let's say, doesn't go inside an if) then the debugger's cursor will stop on the discussed return, so you have a chance to do something before the method has been exited. Don't analyze if the final return can be useful or not, simply write it in the end of EACH subroutine - that will never do any harm. It was a requirement in one of companies I has worked for!
User avatar
Ursego
Site Admin
 
Posts: 111
Joined: 19 Feb 2013, 20:33

Return to Coding Style

Who is online

Users browsing this forum: No registered users and 1 guest


Write RETURN in the end of subroutines, returning nothing

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





free counters

eXTReMe Tracker