This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how robust is enough?  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my latest app has two input dialogs. the program requires each to return a positive integer. if the user types in garbage, the program continues to run. from the user perspective it did nothing. however it did throw a NumberFormatException. should i "fix" it?
my first thought is garbage in garbage out, but i don't like my program throwing exceptions. even if the user doesn't see it.
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try repeating the request: you can blank out the entry field and try again. It might be better to use a regex to verify the input is a number, rather than an Exception.
 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Campbell, both those ideas are better than popping up a new/seperate dialog telling them what they did wrong.
i need to read up on regex. it is new since i first learned java
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You’re welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!