Static init refactoring??

Here a refactoring problem I often encounter.  I wondered if there was
a tool I overlooked to deal with it.

I write several final static inits declaration lines e.g.


  • configuration info for

    private static final Configuration configuration = new


  • where website files are kept

    private static final File webrootDir = new File(
configuration.getWebrootOnEWithSlashes() );

Then I run rearranger and discover to my dismay that the inits are no
longer done in natural order to handle the dependencies between them.
I need to split them into two groups: a set of declarations and a
static init block.  Then I can force the init computation order in the
static block.

It might be nice to go the other way too when safe.
Roedy Green Canadian Mind Products
It is almost impossible to keep things in synch manually. Instead:
-Keep each fact in only one central database (not necessarily SQL),
and access it as needed. Since there is only one copy of each fact,
there is nothing to get out of synch.
-Use some automated tool so that if you change a fact is one place,
it automatically updates the others.
-Write a sanity checker you run periodically to ensure all is consistent.
This is the strategy compilers use.
-Document the procedures needed to keep all in synch if you change
something and rigidly and mechanically follow them.

Please sign in to leave a comment.