Code Smarter, Not Harder
Aug. 2nd, 2024 06:47 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
One of my co-workers had been working on a project to fix a particular bug, but hadn't made a lot of progress on it. I suggested that I should take it over and do it while he worked on something else, since I have more experience in that neighborhood than he does. He readily agreed.
I showed him some of my interim code and he allowed as to how it was similar to the approach he had taken, but that my code was a little cleaner, because I was more willing to change some things that needed to be changed as part of the fix to knock out things that were going to be weird.
After several hours of effort yesterday and today, I suddenly realized that there was a much simpler way to fix this than the horribly invasive approach I was taking. I went into the base class for the offending group of objects, added a boolean to control an option along with an alternate constructor, and then changed one line of code in that class. And then I went to one of the derived classes and used the alternate constructor to enable the option for that class.
Everything appears to work. And I revised the unit test in the neighborhood and it agrees with me.
I'll do some more testing just to be sure, but I think this particular problem is fixed. :)
It's amazing how easy some things can be once you think about them in the right way.
I showed him some of my interim code and he allowed as to how it was similar to the approach he had taken, but that my code was a little cleaner, because I was more willing to change some things that needed to be changed as part of the fix to knock out things that were going to be weird.
After several hours of effort yesterday and today, I suddenly realized that there was a much simpler way to fix this than the horribly invasive approach I was taking. I went into the base class for the offending group of objects, added a boolean to control an option along with an alternate constructor, and then changed one line of code in that class. And then I went to one of the derived classes and used the alternate constructor to enable the option for that class.
Everything appears to work. And I revised the unit test in the neighborhood and it agrees with me.
I'll do some more testing just to be sure, but I think this particular problem is fixed. :)
It's amazing how easy some things can be once you think about them in the right way.