These last couple of weeks, I have been working on a project that led me to think about the risks of code duplication and when would be a good time to get rid of it. Make no mistake, I completely agree that duplicating code of any sort and any extent is a bad idea right from the beginning. In theory, we should never take that route. But in practice, you may have to walk that path if it is in the best interests of your project.
For instance, in the Expression Suite, we have couple of other products that are still further behind in testing infrastructure than Blend. Blend has a well defined automation model that initally was pretty product agnostic, but in time the law of thermodynamics caught up and product specifics found its way in our code making it more and more harder to clean it up. The reasons why produt specifics went in is another good blog post for a later time. Other products in the suite, came along and adopted our testing infrastructure, by copying over our automation stack. It was the best and least risk path at the time. But now it is a growing problem that is coming to bite us. When we change some test code, we have to update the rest of the copies. So, we decided to fix this problem by creating a core test infrastructure and pulling it all the product agostic code into core. The next step is for each of the products to remove the duplicate code and point it to core instead.
All this sounds good, right? Looks like we are heading in the right direction, right? Unfortunately, we are in the last mile of shipping a product to our customers. Making big changes in the last mile has potential of breaking a lot of things with little time to fix. So, the question, I faced for the last couple of weeks was to clean up or not to. I decided to go ahead and give it a shot. It was a two week long project that involved touching every single file of our test code, porting changes over, working with other product teams to make sure the changes did not have negative impacts on their side, and so on and so forth. The big check in finally went in .... We had some new failures here and then, but as of today, we are pretty much where we were before the checkin. The only change is less code duplication at our end.
Overall, I am super excited to see us maintaining just one code copy. Other teams still have to go this route. I guess they too are battling the question of when is the right time to do the right thing. Sometimes, doing the right thing at the wrong time can backfire. In my case, I just knew that it was a good thing. I had a gut feel and it turned out to be right. To someone reading this post, you need to decide.... what is your gut feel?....what is best for your product?....what is best for the customer?
If you expected answers from me, then I am sorry to have taken so much of your time. I am here to only share my experience with you, the decision is still yours to make....