Isaacs: try/catch is an anti-pattern
11–20 of 140 posts
Re: Isaacs: try/catch is an anti-pattern
#12...
> But still, nothing is as bad as the common "On Error Resume Next" that so many terrible VB programs start with.
Assuming "On Error Resume Next" does what I think it does, you can't complain about both of these at once.
Re: Isaacs: try/catch is an anti-pattern
#13Re: Isaacs: try/catch is an anti-pattern
#14I'm not sure how I'm supposed to read this... I guess I need an account?
Re: Isaacs: try/catch is an anti-pattern
#15 try/catch, which blurs the line between errors
that are *mistakes* (accessing a property of null,
calling .write() on a stream after .end(), etc.),
and those which are expected application-level problems
(invalid data, file missing, and so on).
Totally agree.Re: Isaacs: try/catch is an anti-pattern
#16The problem with try/catch, really, is that it makes a tremendous amount of visual noise, which makes sense for critical operations that might crash everything, but just don't make sense when you can tolerate certain errors or checking for proper output with with a conditional looks better and is more appropiate. Obviously then you have an issue with language conventions. How do you check for the returns of a method…
I've seen C code where about 80% of the code is dedicated to error handling and corner cases. Before every statement it has to check the current error status, and after it the return value... it's almost unreadable.
With try/except/finally a lot of that can be cleaned up, by handling the errors higher-up in the call hierarchy where they make sense to handle.
I see a lot of critique of exceptions, but haven't seen one better alternative yet, at least one that doesn't require switching to an obscure programming language.
Edit: this does assume that exceptions are used properly: for errors that should bubble up, not as extra return value.
Re: Isaacs: try/catch is an anti-pattern
#17http://www.az2000.de/pics/screenshots/Screen%20Shot%202011-1...
Re: Isaacs: try/catch is an anti-pattern
#18This is the standard in many languages and one that I believe that java got wrong. It was a little rushed with the whole concept of forcing everyone to handle all exceptions concept and building so many exceptions in for silly things like connection failures and parsing errors that reasonably can be expected to happen constantly in the normal runtime of an application. I follow the rule in almost every language that…
Just to clarify, Java doesn't force you to handle all exceptions (maybe it did at one point in time?). Exceptions which inherit from RuntimeException are unchecked and you can choose whether to handle them or not. Exceptions which don't inherit from RuntimeException are checked
Re: Isaacs: try/catch is an anti-pattern
#19Re: Isaacs: try/catch is an anti-pattern
#20> Try/catch is goto wrapped in pretty braces. There's no way to continue where you left off, once the error is handled. ... > But still, nothing is as bad as the common "On Error Resume Next" that so many terrible VB programs start with. Assuming "On Error Resume Next" does what I think it does, you can't complain about both of these at once.