|
|
|
|
|
by preseinger
1517 days ago
|
|
> Errors-as-return values are less readable than conditions, not more - there's literally more visual noise on the screen. No. When you make a function call, and that call can fail, then the happy-path and the sad-path are both things that you need to manage as a caller. Happy-path and sad-path are two equivalent states that both need to be accommodated by the program logic. Error handling code is not "noise". It is equally important to success-path code. |
|
Yes. There is literally more visual noise on the screen. This is not up for debate - more pixels are lit on the monitor you are looking at.
> When you make a function call, and that call can fail, then the happy-path and the sad-path are both things that you need to manage as a caller.
False - the direct caller is not responsible for error-handling, in general - some transitive super-caller will be. Errors as return values needlessly generate this visual noise for every caller, when not needed, in addition to introducing aforementioned coupling.
> Error handling code is not "noise". It is equally important to success-path code.
You're misunderstanding my point. I never said that error-handling code is noise - it isn't. What is noise is forcing every single function call between the appropriate error-handling point and the error location to have extra useless junk. When there's an error, you should see exactly two things in your codebase: some stuff at the point where the error is thrown, and some stuff at the point where the error is handled - and, given that the place where the error should be handled is rarely the direct caller, you should see nothing in between.