Timeline for Avoiding exceptions for performance optimization
Current License: CC BY-SA 3.0
26 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:40 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| May 5, 2017 at 11:26 | answer | added | Robert Baron | timeline score: 0 | |
| May 5, 2017 at 8:33 | answer | added | Martin Ba | timeline score: 0 | |
| May 4, 2017 at 18:44 | comment | added | candied_orange |
@gnat Good links. I should point out that functions like isValidPhoneNumber() don't surprise me, even in contexts where exceptions are thrown.
|
|
| May 4, 2017 at 13:30 | vote | accept | Microsoft Excel | ||
| May 4, 2017 at 13:07 | answer | added | nvoigt | timeline score: 0 | |
| May 4, 2017 at 8:30 | review | Close votes | |||
| May 9, 2017 at 3:10 | |||||
| May 4, 2017 at 8:13 | comment | added | gnat | see also: Return magic value, throw exception or return false on failure? | |
| May 4, 2017 at 8:12 | comment | added | gnat | Possible duplicate of Clean readable code vs fast hard to read code. When to cross the line? | |
| May 4, 2017 at 0:21 | comment | added | gnasher729 | How many phone numbers are you validating that you think this might be critical for performance? | |
| May 3, 2017 at 23:10 | comment | added | Fabio | Agree, there are exceptions which can be handled, by retrying again, for example. But we talking about "validation" exception. Which are really not expected to happened, because validation is made early. | |
| May 3, 2017 at 23:06 | comment | added | whatsisname | @Fabio: exceptions as flow control can be appropriate in the specific case of handling error situations, as you can have your primary path through an operation assuming the ideal case, and exception throwing can bail out at the right point and handling the exception can clean up. The alternative is arrowheads of status codes and whatnot which can be a nightmare. | |
| May 3, 2017 at 22:54 | answer | added | candied_orange | timeline score: 9 | |
| May 3, 2017 at 22:48 | comment | added | Fabio | @PeterM - again - this scenario is exception - you don't need to handle all possible real exceptions in your internal modules. Internal modules just throw exception - which will be handled on higher layer. The question was clearly about - why exceptions shouldn't be used as validation flow control. | |
| May 3, 2017 at 22:45 | answer | added | Fabio | timeline score: 3 | |
| May 3, 2017 at 22:41 | comment | added | Peter M | @Fabio Except that it might not be your validation logic that is in error. The user may have entered a valid phone number, but the number was corrupted by the ORM when a different module tried to read it from the database. | |
| May 3, 2017 at 22:36 | comment | added | Fabio | @PeterM - correct, but you shouldn't "handle" those exceptions in "internal modules", because if it happens - your validation logic not working. If exception thrown - it should go up to the stack - cancel "transactions", log it, inform user. | |
| May 3, 2017 at 22:31 | comment | added | Peter M | @Fabio Validating the user input at that level is not an exception. But if you have passed that input to a separate and independent module that expects validated phone numbers then from that modules point of view, not having a valid phone number is an exception. | |
| May 3, 2017 at 22:27 | comment | added | Fabio | @PeterM - Validation of phone number is responsibility of application - users will input invalid numbers all the time - this not exception. | |
| May 3, 2017 at 22:24 | comment | added | Peter M |
@Fabio So then it comes down to Is the phone number expected to be valid at this point, or is it an error that isn't? There is not enough context at this point
|
|
| May 3, 2017 at 22:22 | comment | added | Fabio | @PeterM, from your link: Exceptions should not be used to change the flow of a program as part of ordinary execution. Exceptions should only be used to report and handle error conditions. | |
| May 3, 2017 at 22:20 | comment | added | Peter M | @Fabio Some systems use Exceptions as best practice for handling any sort of error. cough Microsoft cough See msdn.microsoft.com/en-us/library/ms173163.aspx for example | |
| May 3, 2017 at 22:15 | comment | added | user232573 | Not an answer, but this particular example may well not be an exception- it's the validation failing because the content isn't valid. | |
| May 3, 2017 at 22:14 | comment | added | Fabio | Exception = an act/case which should not happened. | |
| May 3, 2017 at 22:06 | review | First posts | |||
| Jun 2, 2017 at 22:15 | |||||
| May 3, 2017 at 22:05 | history | asked | Microsoft Excel | CC BY-SA 3.0 |