12 ms·
Complex logic isn't going to be easy no matter how you structure it because the problem in question is intrinsically hard. The real question is whether exceptio
by acdha 14y ago
Complex logic isn't going to be easy no matter how you structure it because the problem in question is intrinsically hard. The real question is whether exceptions are harder or easier to write or understand than the alternatives.
Your example illustrates this nicely: say you jumped on the ideological bandwagon and decided that exceptions are evil and must be avoided. How does this change your code? You can try C / golang style where errors must explicitly be checked & routed through normal flow control - something like this has a million variants floating around:
var recover = 0
for (var idx = 0; idx < xs.length; idx++)
err = xs[idx].update()
if err:
recover = 1
break
}
if recover > 0:
// TODO: hard part goes here
In either case, all you're talking about are minor semantics (i.e. whether you have to explicitly code an if statement, use a flag or goto, etc.). The actual hard problem is what meaningfully can be done for recovery and conflating that with the mechanics of how you reach that code isn't particularly interesting.
- aneth4 14y ago"ideological bandwagon" is precisely correct. It's people blaming their golf clubs for not being good enough, when the real problem is they need to learn to swing properly.