Write code from scratch or use an existing library?
Have you ever faced a choice problem: use an existing library or write code yourself? I never understood this issue and always preferred a ready-made solution. However, recently at work this dilemma again arose, we argued a little as always, but this time, when making a decision, doubts crept in all the same. Read the pros and cons of each approach under the cut.
There is no doubt that taking an existing library, the development of the main functionality will be completed much faster. The developer will focus on the functionality, not the infrastructure, etc.
Libraries are usually written quite universally with an eye to solving many different problems. Therefore, their code is rather cumbersome to understand and is hardly the most optimal for solving your specific task. In the case of your own decision, you write it in the most optimal way and you will sharpen it specifically for your specific use case.
In the case of the library, you have a solution tested by many users. If you still find an error, then just enter the message text in Google, and you will immediately understand what exactly you are doing wrong. On the other hand, if no one has encountered this error, or it is just so obvious that no one writes about it, then here you can spend a lot of time to figure out why something is not working. After all, library code can be rather cumbersome and confusing. Here is a great example.what such a library can turn into. Moreover, it was not you who wrote it, so it will take a long time to understand someone else's code, but for this you need a special skill. It’s good if the library is open source, otherwise communicating with support can still lengthen the search for errors. If you wrote all the code yourself, then you know it far and wide, and finding the error there will be easier than ever. Here are just errors, there will most likely be significantly more, since only you tested this code. Even if you write code from scratch, it is likely that you will lose sight of some rare case that the library has already identified and coded over time.
There are two aspects to this. Firstly, when a new person comes to your team, it is likely that he already worked with the technology that you use as a library (or you immediately hire a person with the condition that he has relevant experience). If you use your own solution, then the new employee will have to understand the details of how it works. Secondly, writing code itself, which is usually written in libraries, is not an easy task. Here you need a highly qualified specialist, or all the other advantages of your own solution will come to naught if the code is written by a pioneer.
To summarize the pros and cons of each approach:
Library
Own development
Your comments are very welcome. It would be interesting to hear what else you need to pay attention to when making a decision.
Speed and quality of development
There is no doubt that taking an existing library, the development of the main functionality will be completed much faster. The developer will focus on the functionality, not the infrastructure, etc.
Optimal Solution
Libraries are usually written quite universally with an eye to solving many different problems. Therefore, their code is rather cumbersome to understand and is hardly the most optimal for solving your specific task. In the case of your own decision, you write it in the most optimal way and you will sharpen it specifically for your specific use case.
Bugs
In the case of the library, you have a solution tested by many users. If you still find an error, then just enter the message text in Google, and you will immediately understand what exactly you are doing wrong. On the other hand, if no one has encountered this error, or it is just so obvious that no one writes about it, then here you can spend a lot of time to figure out why something is not working. After all, library code can be rather cumbersome and confusing. Here is a great example.what such a library can turn into. Moreover, it was not you who wrote it, so it will take a long time to understand someone else's code, but for this you need a special skill. It’s good if the library is open source, otherwise communicating with support can still lengthen the search for errors. If you wrote all the code yourself, then you know it far and wide, and finding the error there will be easier than ever. Here are just errors, there will most likely be significantly more, since only you tested this code. Even if you write code from scratch, it is likely that you will lose sight of some rare case that the library has already identified and coded over time.
Command
There are two aspects to this. Firstly, when a new person comes to your team, it is likely that he already worked with the technology that you use as a library (or you immediately hire a person with the condition that he has relevant experience). If you use your own solution, then the new employee will have to understand the details of how it works. Secondly, writing code itself, which is usually written in libraries, is not an easy task. Here you need a highly qualified specialist, or all the other advantages of your own solution will come to naught if the code is written by a pioneer.
To summarize the pros and cons of each approach:
Library
- + Fast development
- + Code tested by a huge number of users
- + People on the team know how it works
- + Solves problems that you might not have foreseen, I implement the library myself
- + Programmer focuses on functionality, not on auxiliary library
- - A lot of classes, a rather complicated general architecture, so it’s hard to understand the errors that arise
- - Perhaps it doesn’t do some very specific thing that would be very useful for your specific task, so you use a slightly different thing
- - It can’t solve your specific problem in the most optimal way, since inside it contains a bunch of wrappers and flags for other tasks
- - When patching the library yourself, there may be problems with a future version upgrade
Own development
- + Team members know how everything works in detail (until they leave the team)
- + It is easy to determine the cause of the error, since the written code is minimal
- + The most productive solution
- + The ability to develop the library in the direction you need
- - Requires a highly qualified developer to write a good library
- - Long development
- - Contains a sufficient number of errors, especially at the implementation stage
- - New people in the team do not know how it works
Your comments are very welcome. It would be interesting to hear what else you need to pay attention to when making a decision.