I just finished making a change to an ASP.NET Ajax screen from a few years back. It was harder than expected to build and maintain. On this change, I estimated 12 hours and spent 4 days. Granted I also did extensive refactoring to simplify the code.
This is actually some pretty fun code, but I wonder if there was a better route for the original implementation than the one I took.
To start, here's a screenshot:
The Problem
So obviously this is an editable tree of data. The data behaves very differently at each level -- very different sorting/collision rules and so on.
My solution is actually performant and provides an adequate user experience, but it's nearly 2,000 lines of code spanning 11 classes, which is more than I envisioned going in. I'm curious if you've solved similiar problems and if you were able to find a simpler solution.
It looks pretty straightforward at a glance, maybe that means I did something right. But there is some real complexity here -- obviously you can add and remove items at three different levels, and everything sorts similiar to a netflix queue, but with quirks. It also has to detect collisions on the various entities (in the image, if you changed day 5 to day 1, it would have to figure out which one is actually day one and move the other one).
The biggest problem was keeping track of the state, since users don't want to commit changes to the database as they work. I thought it might be possible to use the actual controls (nested repeaters in this case) to represent this interim state, but that ended up being a dead end due to complexities related to the underlying data.
The Solution
To solve this, I created a full blown XML representation of all the data, which was actually great in some ways since I was able to use LINQ to do a lot of heavy lifting around sorting and querying. Still, there is a lot of code in here related to syncing up the xml to the html and so on, and I had to make a pretty hefty abstraction on top of the xml to make it easy for me to work with it in code.
In case you're interested, I am currently persisting the XML to session state so that it will survive across callbacks, but eventually that should go into the database.
One colleague told me it would be better to use Flex or maybe Silveright for something like this, and I think that might be true since those are both much more stateful, although Silverlight was not ready for prime time back when this started, and I don't know Flex. Maybe using a temp table instead of xml would have been superior in some way.
I'm looking to learn and improve -- what have your experiences been with this type of problem?