I think this is a very interesting take on something I never really thought about. I consider myself to be quite strict about the semantics of code, so this comes as a surprise that this has never crossed my mind.
If I may ask, what may be the other valid use cases for void calls besides logging?
There really aren't many valid use cases. Any IO operations which may include logging.
Then any entry points to an app. Eg the main() func, setting global config, automapper, DI or task runners such as Grunt, Gulp etc and Test Frameworks. In principle only anything super high level, and things that could affect the global state.
Yes that would be right! The main function call can be either, and it's down to the user to decide which to use. I would recommend it returning an int, but then I think you would have guessed that already 😊
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think this is a very interesting take on something I never really thought about. I consider myself to be quite strict about the semantics of code, so this comes as a surprise that this has never crossed my mind.
If I may ask, what may be the other valid use cases for
void
calls besides logging?Thanks, It drives me up the wall.
There really aren't many valid use cases. Any IO operations which may include logging.
Then any entry points to an app. Eg the main() func, setting global config, automapper, DI or task runners such as Grunt, Gulp etc and Test Frameworks. In principle only anything super high level, and things that could affect the global state.
By "entry points to an app", am I correct to assume that these include event listeners?
Also, just a tiny nitpick: doesn't the
main
function call ideally return an integer denoting whether or not the program was successful?Yes that would be right! The main function call can be either, and it's down to the user to decide which to use. I would recommend it returning an int, but then I think you would have guessed that already 😊