Saturday, April 17, 2010

Super-tool For Refactoring

One of our projects at work involves refactoring the code into layers (UI, business logic, data, service, and so forth), and then vertically into components within each layer.

In many cases, the work involves mechanically moving classes to their correct layer, splitting classes, moving methods, and sometimes adding listeners or Spring initialization to remove upward dependencies.

The work is tedious. There's nothing particularly creative about it. It's just a slog through a million-plus lines of code.

Refactoring tools are available, but they are basically tedium reducers. They automate mechanical transformations at the lexical level, but they don't understand anything.

I want more. A lot more.

I want semantics instead of syntax.

Somewhere in the Platonic realm, our program exists in the form of its true, perfect nature. I want refactoring tools that make it easy to move a program towards its ideal form.

Imagine standing in front of a big display like the one in Minority Report, lighting up a long sequence of nested if/then/else/case statements, and selecting "Infer Rules Engine".

Imagine pointing to other sections of the code and being able to select operations such as:

"Infer State Machine"
"Recode Without Side Effects"
"Remove Programming By Exception"
"Replace Static Initialization With Spring"
"Make Stateless"
"Extract Declarative Configuration"
"Replace With Annotation"
"Manage In Cache"
"Substitute Composition For Inheritance"
"Reimplement With [Name of GOF Pattern]"
"Extract To Presentation"
"Canonicalize To JEE"
"Promote To Web Service"
"Internationalize"
"Make Testable"

all while maintaining source-control history.

(Moved from http://jimshowalter.blogspot.com/2010/03/one-of-our-projects-at-work-involves.html.)

No comments:

Post a Comment