Anticipation

Should an application anticipate and hadle events that in theory should never happen?

  • Yes

    Votes: 4 57.1%
  • No

    Votes: 2 28.6%
  • Other

    Votes: 1 14.3%

  • Total voters
    7

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
Is it good programming practice for an application to anticipate and handle events that in theory should never happen?

Examples:

  • Should a PHP application react to a database with mismatched IDs, that in other cases would produce an error?
  • What happens if there is one page that adds an order ID and a order, then the next page encounters an order id without an order? Should the page react to it or exit with an error?

In my personal opinion, I think no. I think that a developer should spend more time ensuring that those events don't happen rather than reacting to them. Too much headache.

I have experienced errors on x10 that 'in theory should never happen' several times XD
 
Last edited:

smurfboi76

New Member
Messages
23
Reaction score
0
Points
0
I said other because I think it has a lot to do with what the program/application is going to be used for. If for example you wanted to create and error free program/application (aka Drive you self insane). Then yeah obviously you would have to think of things that shouldn't be possible.

I think when it comes to programming you have to think more of what is the program going to be used for. If it is going to be used in a Video Game situation then maybe you should look in to some of the errors that could be caused by different computers. If you are creating an online app and it is going to be interacting with other apps. One make sure you don't have very much over lap because of the obvious problems like 2 orders being created for every one actual order. So I would say try to eliminate as many errors as you can with some protection from the possible but unlikely errors that could come up in the future.
 

lucasjnjones

New Member
Messages
7
Reaction score
0
Points
0
"In theory, theory and practice are the same. In practice, they are not."

Definitely.

I don't agree with your argument that effort should instead be dedicated to prevention - while it is important to make sure the events do not occur, you may not always have a great degree of control over the target environment to which your application is deployed to ensure that is the case.

Possible scenarios: Other software has bugs which cause your application to fail. The user has some odd dynamic library issue that messes things up. Any servers involved could have non-standard configurations which cause your program to fail. There are infinitely many other situation which could cause problems.

Do you think your users would prefer incorrect results, catastrophic crashes or data corruption over (at worst) a log message/error box with instructions on how to resolve the issue? I hope not.

Disclaimer: I agree with everything I've said here. I have to admit, however, that I don't always follow these guidelines -- I'm to lazy when it comes to personal projects. (I do most of the time, though!)
 
Top