File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to refactor this method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to refactor this method ?" Watch "how to refactor this method ?" New topic
Author

how to refactor this method ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
how to refactor this method ? make it concise... too many "try-catch" and "IF-ELSE".

Thanks.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18108
    
  39

It depends on what you mean by "concise"... if you mean "as few lines of source as possible, how about...



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

There isn't much I would change. Just one thing: move the return true inside the try:

Or even shorter:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: how to refactor this method ?
 
Similar Threads
silly but severe problem
Hibernate Query
try...catch ...return
How to check if String() value is numeric