As an engineer, I have often been conflicted about the interplay of code reuse and dependency management. It is innate behavior for me to not want to repeat myself and it is through hard and painful experiences that I have learned to be hyper-critical of all new dependencies.
Why re-invent the wheel? Because the existing wheel comes with lots of strings attached. This article does a good job of explaining the pitfalls in depth:
Redundancy vs dependencies: which is worse?
If it is my wheel and it breaks, I know how to and am able to fix it quickly and cheaply (measured in time). If I depend on someone else's wheel, now I have lots of problems. Will they fix it and when? Will their new version introduce new things I am not expecting? Maybe they too have their own dependencies. That's to name just a few.
I was on a team where a large third-party Java library was added to the project for the sole purposes of using the "isBlank()" function. That was not a good trade-off of re-use and dependencies. I hear the Javascript/npm world has this same sort of problem in spades.
Too often the Don't Repeat Yourself (DRY) mantra is used as a gospel, devoid of the dependency cost. I've seen development cultures where adding dependencies is done often and effortlessly: it does not even register that there should be a decision process around this. As a group, we need to be more thoughtful about the trade-offs we are making when introducing a dependency and to assign it the proper cost.
Here is another good article related to this theme:
No comments:
Post a Comment