Saturday, August 4, 2001 03:20 AM
You need to bear in mind that everything in Java must be done in the context of a class. You can have something approximating global methods by using static methods or classes, but you need to carefully analyse your code to ensure that you aren't sacrificing object orientation for the wrong reasons here.
I think that you need to approach Java source code refactoring with a rather strict OO hat on. In my experience, you don't simply split the source file, you need to split the resultant class file. This means that you need to re-analyse your code and ask yourself if there is functionality contained therein that you can refactor either by inheritance or delegation and come up with new class relationships based on this analysis. This is, in your words, "kludgey", but Java is more strictly OO than other languages and so it is more correct to split your classes and not your code.
Note that most of the documentation that you will see will make strong recommendations that you have a good test strategy in place before refactoring - regression test will be extremely important as you proceed.
As for your analysis yielding results, well, it depends on individual circumstances. You might like to look at some of the articles on the web concerning java refactoring to get some more insight into what your particular project needs.
Have a look at Make bad code good - Refactor broken Java code for fun and profit from Javaworld. There are a number of books on refactoring out there as well, along with articles and books on design patterns, which might be useful to you. In addition there are some tools which may help - a quick search of the Net yielded Transmogrify and I am sure that there are others (I know that there are products such as JTest which perform static analysis of source code - maybe they could be employed to fulfil your requirements...)
Finally you might like to refer to the patterns FAQ and forum for more information from people who know more about this than I do.
My tuppence worth...