Freitag, 29. Mai 2015

Fixing everything two ways

Today I had an ugly programming problem where it looked like an object in the code "forgot" members. Well it turned out that this member variable did not forget anyting - it was simply replaced in an unexpected place in the code. The problem could be solved easily after I had discovered that. All very oscure and nerve wrecking and it took me more than 2 hours for something that should have taken just a few minutes.

When I thought about the problem afterwards it occured to me that it would be good to also take care of this replacement problem, because it was far from obvious and I might run into the problem again. So I went back in and spent another 7 minutes (!) making this replacement problem go away (now it is not a member any more, but an argument to a method - because it is only needed by this one method). I'll now never have this problem again...(Yeah, basically this was bad design in the first place, but hey, that code was almost 10 years old... ;-)

All this made me think of an old article by Joel spolsky and made me realize - fixing stuff two ways is more universally useful than just for customer service...

PS: um, well this is also a variation of the Boy Scout Rule.