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

how to refactor this method ?  RSS feed

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to refactor this method ? make it concise... too many "try-catch" and "IF-ELSE".

Thanks.

 
Henry Wong
author
Sheriff
Posts: 22827
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what you mean by "concise"... if you mean "as few lines of source as possible, how about...



Henry
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't much I would change. Just one thing: move the return true inside the try:

Or even shorter:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!