Naming convention: exit status, exit code or return code?
This is maybe a silly question but what should be the proper naming for the exit code variable?
exit_code
开发者_运维技巧exit_status
return_code
- ...something else?
I'm referring to both application or function exit codes.
I know that all of them are synonyms but it would be nice to have a single one, just for consistency.
Which one should it be, and why?
Use the same name as the other developers in your team. If that's not obvious, agree one with them.
Then get on with programming and don't sweat this sort of stuff.
In our latest application we are using ReturnCode. For some of us the word "Exit" brought up a feeling that something went wrong in the method call. Return is more neutral and it can be used naturally to represent both the positive and negative results.
Overall I think that you can choose anything you want, as long as you are consistent.
精彩评论