Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
dcuny said...

The idea that a program should crash is baffling to me. While it may be a theoretically correct behavior, it's not a desired behavior.

Consider the following use case: A user has created a file using a text editor that can save in formats X, Y and Z. The user has been working on multiple documents for the last half an hour, and are getting ready to save them. Unfortunately, there's a trivial bug in the editor, where the length of the filename is miscalculated as 1 character too long.

The user tries to save a file they've been editing in format X.

Which of the following behaviors would the user desire:

  • The program should crash and the user's data should be lost, protecting the user from potentially corrupted data.
  • The program should crash, but save the files as TMPnnn.zzz which the program will find when it loads again.
  • The program should inform the user that there's a problem saving in format X, but continues to run and allows them to save it in format Y or X.

I can guarantee you option 1 is not the "correct" behavior, either as a user, or a developer.

A bug in the editor should result in a crash, and the developer should correct the bug. If possible, the reason for the bug should be communicated to the user, but regardless if an incorrect result can occur then the user is better served by a crash then by the output of incorrect data.

Of course, the class of errors represented by an illegal filename would be classified as a recoverable error, not necessarily an irrecoverable one. It's a situation which depends on user input and should be checked by code so...

I'm not sure that your example is valid.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu