Timeline for Are exceptions as control flow considered a serious antipattern? If so, Why?
Current License: CC BY-SA 4.0
34 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 11 at 18:07 | answer | added | bobobobo | timeline score: 0 | |
Aug 22, 2023 at 10:36 | comment | added | tottinge | Python exceptions are how you say "I can't do that" - that's pretty much the only use; we don't return values by raising a tuple or anything. | |
Jul 20, 2022 at 21:39 | comment | added | JosephDoggie | @truthadjustr: I've always thought that goto is overly criticized so I agree to a certain extent. I used to do assembly language, and a variant of goto such as jump, branch, and their conditional variants usually arise. However: I wouldn't say you like goto in a job interview. | |
Jul 20, 2022 at 21:37 | comment | added | JosephDoggie | I can't give a specific answer to your question. However, to me exceptions quickly become the "tail that wags the dogs". On the other hand, one has to deal with web-connections that don't come, database connections that don't come, etc. Thus: a conundrum .... | |
S Jul 20, 2022 at 15:51 | history | suggested | Neuron | CC BY-SA 4.0 |
this edit should have been a comment. Questions should focus on asking a question and not be cluttered with historic artifacts. Therefore, "Update"/"Edit" headlines are discouraged: to https://meta.stackexchange.com/a/127655/316262
|
Jun 2, 2022 at 17:53 | review | Suggested edits | |||
S Jul 20, 2022 at 15:51 | |||||
Jan 10, 2022 at 9:09 | comment | added | JonasH | I would note that on some languages/platforms creating an exception is fairly expensive. On .Net it needs to create a call stack, so is much more expensive than return codes. | |
Jan 7, 2022 at 14:53 | answer | added | b_levitt | timeline score: 2 | |
Apr 25, 2019 at 0:27 | comment | added | daparic |
C++ exceptions are more worst than goto . If you see a goto hell statement, at least you can be certain it will indeed go there. But in the case of an exception, you cannot know where it will go. In the call sequence A()->B()->C() , an exception thrown in C will not propagate to A if B catches it. If somewhere in C catches, it will not even propagate to B. If there are finishing codes in A, these will not be invoked. Of course, C can re-throw it. But you see now the point, unlike goto which is certain, exception flow is not. We even drop the honest goto because of its non-linear nature
|
|
Mar 1, 2018 at 15:22 | comment | added | binki |
That sounds a lot like what async await does, actually. Except that async and await are better for numerous reasons (somewhat less overhead, immune to overgeneralized catch clauses, …).
|
|
Jun 30, 2017 at 12:46 | comment | added | user109707 | Aren't exceptions always controlling the flow of an application? | |
S Oct 20, 2016 at 17:29 | history | suggested | bakoyaro | CC BY-SA 3.0 |
Edits for grammar and readability
|
Oct 20, 2016 at 15:39 | review | Suggested edits | |||
S Oct 20, 2016 at 17:29 | |||||
Jun 29, 2016 at 5:46 | comment | added | cwap | Another related question on SO: stackoverflow.com/questions/729379/… | |
Jun 28, 2016 at 23:51 | answer | added | MirroredFate | timeline score: 15 | |
Mar 18, 2016 at 10:04 | history | protected | gnat | ||
Mar 18, 2016 at 6:40 | comment | added | Houen | To add to the existing answers, here is a short guideline that has served me well: - Never use exceptions for "the happy path". The happy path can be both (for web) the entire request, or simply one object / method. All the other sane rules still apply, of course :) | |
Dec 29, 2015 at 4:39 | comment | added | Fuhrmanator | Wikipedia's definition of anti-pattern says it's common. Given you never saw this again, and I've never seen it ever, maybe it's just bad style and not technically an anti-pattern? | |
Jan 14, 2015 at 11:02 | history | tweeted | twitter.com/#!/StackProgrammer/status/555318953841786880 | ||
Jan 11, 2015 at 8:16 | answer | added | Lukas Eder | timeline score: 26 | |
Oct 20, 2014 at 12:49 | answer | added | Joop Eggen | timeline score: 7 | |
Oct 20, 2014 at 12:25 | answer | added | Pete | timeline score: 20 | |
Aug 15, 2014 at 14:58 | comment | added | Thomas Eding | If I were to do such a thing I Java, I certainly would not throw an exception for it. I would derive from some non-Exception, non-Error, Throwable hierarchy. | |
Mar 5, 2013 at 3:43 | comment | added | Erik Reppen | I suspect you're being ironic or bitter. I appreciate both. Just keep your damned dirty empty catches out of the JavaScript. | |
Mar 5, 2013 at 1:37 | comment | added | user16764 | No. In Python, using exceptions as control flow is considered "pythonic". | |
Mar 5, 2013 at 1:07 | answer | added | Jörg W Mittag | timeline score: 37 | |
Mar 4, 2013 at 23:36 | answer | added | gahooa | timeline score: 8 | |
Mar 4, 2013 at 23:22 | answer | added | Karl Bielefeldt | timeline score: 9 | |
Mar 4, 2013 at 23:02 | history | edited | Aaron Anodide | CC BY-SA 3.0 |
added 172 characters in body
|
Mar 4, 2013 at 22:46 | vote | accept | Aaron Anodide | ||
Mar 4, 2013 at 22:41 | answer | added | Mason Wheeler | timeline score: 186 | |
Mar 4, 2013 at 22:40 | answer | added | blueberryfields | timeline score: 182 | |
Mar 4, 2013 at 22:33 | comment | added | Eric King | Related question: programmers.stackexchange.com/questions/107723 | |
Mar 4, 2013 at 22:27 | history | asked | Aaron Anodide | CC BY-SA 3.0 |