Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how robust is enough?  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4585
6
Java Python 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: 53760
127
  • 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: 4585
6
Java Python 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: 53760
127
  • 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!