First one, because of following reasons..
- As mentioned by "01" , easy to log and debug
- Easy to refactor
Your code should always be in this pattern..
- Declare variables
- Initialize variables
- Do Processing
- Clean up !!!!
- Return
In this pattern, it's easy for other people to understand how your code behaves, where to look for problems, because always "Do Processing" is the part where your business logic stays and you can certainly refactor 3rd step without affecting 4th and 5th.
If you ever get chance to see largely coded "Windows COM/DCOM Technology Source Code", they always have very standard pattern of using retval construct, and only by using standard pattern one team can achieve designing bigger and better systems, one lazy programmer can write smallest logic in terms of number of lines, but its never good for enterprise applications.
We spend lot of money on code standard tools, and we even write more code then often necessary but at enterprise level, standard practice and less complicated codes are better to maintain and grow.
By saying this, I agree that even in hurry I do not follow exact same pattern by myself many times, but I also have faced consequences, when code grows bigger, the logic becomes more complicated, the logic refactoring becomes difficult.
To write less code, we use refactoring, but not complicated logic hard to understand.
Even if you declare or do not declare
retval, if you get chance to
disassemble any code, you will see
that compiler always declares one
variable internally that is used for
return anyway.