Refactoring a web forms application to modern paradigms
For the last two years or so, I was working on a partial rewrite of the web shop I am developing.
The original web site was done in quite a hurry using whatever tool would fit the current situation. So I ended up with a behemoth consisting of asp.net webforms, 4 different data layers (the now defunct gentle.net, subsonic, nhibernate and plain dataviews/adapters/boilerplate code), no real business logic (there were these classes I used to store my data in, but there was no actual logic embedded there. I guess these objects usually are referred to as DTOs (Data Transfer Objects)).
So whatever happened to these DTOs, happened due to logic embedded in thousands of clicked, loaded, databound, changed, etc… events in web forms. It did not take a lot of time, maybe a year or so, and this entangled spaghetti ball became impossible to further develop. Everything had so many side effects, even worse relied on so many side effects, that touching any part of the code would lead to endless debugging sessions.
Well, I was aware of that danger and also, that the initial lack of design eventually would need to such a situation. This situation was caused both by the hurry in which the site had to be up and running and by the lack of options when I started – either they did not exist yet or very very early in their conception. In parts of the application I gradually introduced different open source solutions, to see, what the benefit would be. In parts the original application consisted of quite a few spikes in the most different directions.a
I generated mails, sent to customers with nvelocity. NVelocity s a side project of the great castle stack, so it was only a matter of time until I started to discover Castle Monorails, which I used for some functionalities in the administrative interface. When Gentle.net was officially lied to rest, I had to look for an active supplement and everything pointed into the nhibernate direction, so I went with that.
Soon enough it was clear in which direction I needed to head. I based the upcoming architecture on:
- Castle Windsor as IoC container
- Caste Monorails as the application framework
- NHibernate as my data layer
- JQuery with a lot of JSON usage for all my GUI needs
More on each of those in future posts.