Some background: A few months ago, I decided to put a little AJAX in an app I inherited. The problem was a huge form that used post-back to fill some dropdown boxes based on values in other elements. I coded the AJAX all from scratch, or near scratch anyway, mainly because ATLAS was still in early beta and this is a 1.1 app. Anyway, everything worked well enough, or so I thought.
This is where good end-user testing is so important. You see, since I inherited this beast, I don't know how everything is supposed to work. Some of the nuances are not always apparent to me and I might miss them. For example, when creating a new form, a set a parameters will autofill the main form. When I inserted my AJAX streamlining and tested, everything worked great from my perspective, a new form was created with some of the values prepopulated. What I didn't realize was that the dropdown list was not being read correctly by the codebehind, because from it's perspective, it was empty the last time it saw it and was not reading the form post value. I don't know yet whether this is my fault or the friendly designer who wrote this screaming... thing, but the end result is that not all of the values were filled that were supposed to.
So here's where my post title comes in: When I put the AJAX calls in, I did not change the code-behind. I simply added my JavaScript and disabled the elements' autopostback attributes. When developing systems I don't understand, I make as little impact as possible and comment like hell, so someone can come in behind me and fix what I broke. I also CYA in comments for who requested what changes and why. Fixing broken code reminds me constantly about the importance of good commenting, despite that I don't do very good job of that in my original code. Anyway, the implementation of some business logic features and these got rolled up, tested of course, and deployed late yesterday.
Well, this morning I get a frantic call and a HD Ticket: Yep, the form is not populating all of the values. It needs to be fixed immediately! And behold! It only took 15 minutes to find the cause and simply turn on the autopostback and disable the JavaScript. All in the aspx file! If I had removed or commented the methods in the code-behind, I would have had to recompile everything and risk version conflict; I had started on the next set of changes, of course.
So there's a lesson here, I think. Although it is not the most efficient coding technique in the world, there is ample reason to not remove a method that you think is unused, especially if you do not understand the total impact of a change. Let it sit there, all it is hurting is a tiny amount of overhead and some compile time. This time it really saved my bacon! Next time it will probably bite me.
Disagree? Send me your exeriences in comments!