DEV Community

Discussion on: Exception handling is an Antipattern | Avoid when possible

 
cicirello profile image
Vincent A. Cicirello

As one who teaches SE courses now and again, I absolutely do understand antipatterns. Your blanket declaration that exception handling is an antipattern is absolute nonsense. A language feature alone, without usage context, cannot be an antipattern.

There are antipatterns involving exception handling, such as the hiding exceptions antipattern, the raising unrelated/nonspecific exceptions antipattern, the catch then re-raise antipattern. There are also many exception handling related patterns.

But no, exception handling itself is neither an antipattern nor a pattern.

Thread Thread
 
ziaulhasanhamim profile image
ziaulhasanhamim

In your logic gotos are good to use too. Because they are also language feature. Same goes for pointer you should use that too. Don't forget goto, pointer everything provides a value. But if write C# code using that most people are gonna say avoid them. Same goes for exception they provide a value but still it's better to avoid. Not all language feature is good and shouldn't be used.

Thread Thread
 
cicirello profile image
Vincent A. Cicirello • Edited

Those are also neither patterns nor antipatterns. They are just parts of languages that you can either use or not use. It is how you use them that may be a pattern or may be an antipattern or may be neither.