Re:Replacing Throwing Exceptions with Notification in Valida...
by dragonwriter on Saturday December 13, 2014 @08:04PM
(#8747102)
> I've never heard a justification for it,
The usual justification I've heard is that it is superior for the flow of operation for expected cases to be clear from inspecting the code, and the use of exceptions breaks that up.
> or a rigorous explanation of what "expected" means.
This is a problem. I have my own construction of what it makes sense for "expected" to mean in this context [0], but its not clear to me that that's what others offering this rule necessarily do mean by "expected", it usually seems to be fuzzier (which is problematic.)
> Exceptions are a language construct, like variables, classes, and for loops. As with those other constructs, use them when it results in a program which makes sense. But that's a judgment you can only make on the program, not on the construct.
I generally agree, but I think that -- with the understanding of "expected" relating to the advertised constraints/expectations of the unit of code in question --
its a fairly good rule of thumb for when using exceptions results in code that makes sense.
The usual justification I've heard is that it is superior for the flow of operation for expected cases to be clear from inspecting the code, and the use of exceptions breaks that up.
> or a rigorous explanation of what "expected" means.
This is a problem. I have my own construction of what it makes sense for "expected" to mean in this context [0], but its not clear to me that that's what others offering this rule necessarily do mean by "expected", it usually seems to be fuzzier (which is problematic.)
> Exceptions are a language construct, like variables, classes, and for loops. As with those other constructs, use them when it results in a program which makes sense. But that's a judgment you can only make on the program, not on the construct.
I generally agree, but I think that -- with the understanding of "expected" relating to the advertised constraints/expectations of the unit of code in question -- its a fairly good rule of thumb for when using exceptions results in code that makes sense.
[0] https://news.ycombinator.com/item?id=8746874