• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 331
Python Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic