I'm attempting to refactor an existing Winform application to use the MVP Passive View pattern. The application's UI, business logic and data storage code have been freely intermingled for years. It looks like it either started out with separate layers or someone attempted to separate it into layers. In any case the layer boundaries weren't respected.
Since the forms directly manipulate the domain objects and the data source(and vice versa), my first task is to create presenter/controller objects and delegate those responsibilities.
The application is a .NET 1.1 app and I'm developing in VS.NET 2003 with a rather limited refactoring add-in. I used a test generator for the existing code to create the boiler plate unit tests then went through and hand edited each test. Granted, this winds up testing what the code does, not necessarily what it's suppose to do. For new classes I'm doing TDD.
Any tips, resources, pitfalls to look out for with a refactoring effort of this scale?
A couple of resources I already have at my disposal:
- Collection of programming books; Refactoring, PEAA, WELC
- The internet (obviously)
- Large quantities of caffeinated beverages
Update: As an example what steps would you take to turn this:
private void OneOfManyFormEventHandlers(object sender, System.EventArgs e)
{
string LocalVariable;
decimal AnotherLocal;
if (!this._SomeDomainObject.SomeMethod(ClassField, out LocalVariable, out AnotherLocal))
{
MessageBox.Show("An error occurred calling method");
return;
}
this.FormControl.Value = LocalVariable;
this.AnotherFormContorl.Value = AnotherLocal;
this.AnotherPrivateMethod();
}
Into this:
private void OneOfManyFormEventHandlers(object sender, System.EventArgs e)
{
this.FormPresenter.DoSomething();
}