wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes How to refactor methods form a utils class to most relevant places? 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 » Engineering » IDEs, Version Control and other tools
Bookmark "How to refactor methods form a utils class to most relevant places?" Watch "How to refactor methods form a utils class to most relevant places?" New topic
Author

How to refactor methods form a utils class to most relevant places?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
I am looking for a tool or a way to refactor w large utils class with lots of private and public static methods and put those methods to the classes that are accessing them. In total there 12 classes in two packages that use the methods in the utils class. If you know any tool or any best practice to refactor check where each method or set of methods should be placed please let me know.

Some of the classes in those packages have common ancestors which can be good place for the common methods but some classes are isolated.

Thanks.
Sumit Bisht
Ranch Hand

Joined: Jul 02, 2008
Posts: 329

Are you having an open source project ?
If it is possible to contact the project's owner, you can have this discussion there.

However, Utility classes generally do opposite of what you seem to be proposing- they externalize the code from their users to a central class to promote re-usability.
As they grow in size, one possible refactoring I can come up with is creation of multiple utilities, extending a common utility class.

While your assumption about common ancestors is valid, but many methods might also be required by non-common ancestors to execute in isolation and/or cause their classes to lose cohesiveness.

Edit:
Tool: In eclipse, Alt+Shift+T brings up the refactor menu (you can use commands to refactor the code directly)
Resource: Martin Fowler's refactoring book+website
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to refactor methods form a utils class to most relevant places?
 
Similar Threads
Buildpath problem with Eclipse
Can't RUP be an instance of Waterfall ?
Axis2 aar file structure question
How to make a class smaller
Using Different Packages based on input