Why reinvent the wheel?
In this blog post I want to focus on whether it's good or bad to reinvent the wheel in the field of computer development referring to creating your own code alternatives over using existing ones. Many people have different opinions about this question, and while I have my own, I will try to have an unbiased opinion. Let's start!
I hate to reuse code :unamused:
This is often a very good choice, contrary to popular belief in some cases. The main advantage is that you've got full control over the software, which is often essential, but you will have to deal with your own bugs which is a good or a bad thing depending on how active other alternatives are.
Evaluating a ready made module is very time consuming if you are worried about security and/or performance (Psst, you should be). Furthermore, some shortcomings will surface only after extensive use, when it's too late to switch to another better alternative.
There is as little code to understand as possible, as the implementation is your own. This is a large benefit when you need to write an extension as there is less code to understand and to modify.
Extending a ready made module causes a big communication overhead (discussions with the developers maintaining the ready made project). On the other hand, branching the code is untempting because you won't be able to reap benefits from bugfixes and extensions.
All previous remarks assume the ready made project is open source. In most cases, when using a closed source project, there is far too little documentation available. This is especially true with frameworks.
The license agreement of the project you are thinking about to use may also be too strict.
Open source rules! :sunglasses:
If you need a performant and already tested module, search for popular open source projects before starting your own, mainly because:
- The functionality already exists and is known to be stable. Moreover, you are going to create another alternative that won't add anything new.
- Your version will most likely introduce bugs or constraints (e.g. your version isn't thread-safe).
- As the group of people that will be working with your own implementation are close to you, you most likely won't try to create a good documentation because you don't plan to make it open source.
- Unit tests are important! Most open-source alternatives will have unit tests and your version will be lacking them, and if you add them, you will become to see that your project isn't as performant as you thought.
There certainly are situations in which code reuse is the best option, but it is not always the best choice. Reuse in software development is certainly different from the reuse of bricks when building a wall, for example; or from reinventing the wheel when designing a car.