Code Reuse: a Blessing or a Burden?

In the world of development, coders are constantly faced with the problem of creating efficient code under a very tight deadline. The idea of Code Reuse, simply the use of code created by another developer, has been a staple concept in the world of programming since the start of development. Whether it is an open-source library or code written by a stranger on a frequently-visited forum, every developer has utilized code reuse at one point. Code reuse definitely has its place in development, but should we rely so heavily on this model?

The first thing you need to think about before using someone else’s code is, “Do I have the right to use this code?” It’s becoming commonplace to see a lawsuit based on one company stealing code or concepts from another. But, beyond the legal reasons against using other’s proprietary code, there are also the ethical obligations that everyone should consider for leaving this code alone. No developer wants their own work to be stolen, so it’s also their responsibility to not steal code that doesn’t belong to them.

Not all code is proprietary though. There are entire communities that revolve around open-source libraries, made to benefit everyone. Here at Algonquin Studios, we have a monthly meeting during which all of the developers get together and talk about the technology they either are working on or want to work on. Our last meeting was based around third-party solutions and not “reinventing the wheel.” If there are solutions to your problem already in existence, why should you waste the time of your employers and clients?

I agree with the idea that if a proper solution exists, there is no reason to recode the solution. The fine line lies with the word “proper”  though. Too many times, I’ve seen a complex solution to a problem be reused in many places it shouldn’t. Usually the solution gets a “band aid” so that it works within the scope of the new problem but this just evolves as more closely-related problems emerge and eventually the coder ends up with inefficient code that barely solves the problem. The world of development has  begun to rely on third-party libraries and frameworks and other people’s code so much that they sometimes have no original code in their project and there needs to be a happy medium between quality and speed of development. Sometimes it’s worth it to rewrite an entire procedure that isn’t quite getting the job done. Sometimes you have a completely unique problem that someone else just hasn’t encountered before.

I still go back the “don’t reinvent the wheel” idea. If you can use other code that’s available and satisfies the problem in an efficient manner, then it’s a good solution. We all need to realize, though, that wheels come in different sizes and shapes. You wouldn’t want to put a hamster wheel on your car, nor would you want tractor wheel in your amusement park instead of a Ferris wheel. In the end, code reuse is a blessing to developers. Being able to create rich software at a fraction of the time spent is a very powerful tool. The developer just needs to learn when it is appropriate to reuse code, and when they should develop a solution specific to their problem.