software development

When should we consider using third-party libraries?

WK

William Kurniawan

Jul 24, 2020

The most crucial advantage of using third-party libraries is that it helps you to save time because you do not need to develop the functionality that the library gives. Instead, you can focus on the core features of your website. Even though you still need to allocate some time reading the documentation and understanding how to use it, this is just a small amount of time compared to the time will be required to develop and test its functionality from scratch.
On the subject of testing, another benefit of using a third-party library is "proof of use". A well-known library will have been used in multiple conditions and scenarios. The feedback loop from this will have resulted in bugs being reported and resolved. So, using a verified third-party library should not compromise the overall quality of your website.

Risks of using third-party libraries

Depending on a third party library means that your code is tightly coupled to that library. Let's say at some point you are required to implement more features in your app. And, the library you are using does not support the necessary functionality. In this case, you might have to find other libraries or rewrite the feature from scratch. This makes you have to spend some time to adapt it to the new library or write the function from scratch. There are, of course, ways to avoid this, such as using a wrapper or bridging component for the library. This way, your code does not directly call the library, but an abstraction instead.
Another possible risk is that using an excessive number of libraries will bloat your website by increasing its size. In turn, this will eventually affect the performance of your website. In the case of web development, it can contribute to a lower rank on Google due to slow response time.
Last but not least, the use of third-party libraries might have some security concerns as vulnerabilities in open source libraries are frequently targets for hackers.

How do I choose the right third-party library?

To answer this question, I have included the evaluative process I use when selecting third-party libraries. Once you have a candidate, ask yourself the following questions to see if it fit for your needs:
How popular is the library?
In GitHub, for example, it has crowdsourced popularity evaluation built-in. Start by looking at how many stars the repository has. And then check the number of pull requests submitted for that library. When many developers trust a library, it is a good indicator of its excellent quality.
How well-documented is the library?
Quickly dive into the code and try to assess how well structured it is. Also, read through the README or its official website. Typically, good developers document clearly. A well-documented library will help make integration quick and easy, and excellent code quality will probably mean a reliable and performant library.
Does the library have the correct license?
Another essential factor that might influence your decision is licensing, as the use of libraries can be restricted based on usage. For example, you may find there are limitations if you intend to publish your product commercially. So, make sure that you are following the specific terms of each library you have used in your code.

Conclusion

Hopefully, this article has helped you to decide whether you should use a third-party library in your projects. Each project is unique, so treat it as such, and try to get the benefits and understand the potential risks for the particular third-party library you are using.
Libraries are not naturally evil, and using them does not make you a lazy developer. When chosen carefully, they are a great time-saving tool. However, when developers do not take a thorough and thoughtful evaluation process of selecting the right third-party libraries, things can go wrong.

Copyright © 2020 William Kurniawan. All rights reserved.