How to choose an open source project?

Original address: Please scan the WeChat public account of stormzhang after the article - AndroidDeveloper


After such a long period of observation, I found a phenomenon that the reading volume of articles written by myself is relatively high, while the reading volume of some articles contributed by others is relatively low. I have concluded that there are probably the following two reasons. :


1. Your attention to me is all directed at me, whether it is my charisma or my personal inspirational experience, all of you want to read my own original articles. This should be commonly known as the "Internet celebrity effect". ;


2. Most of the articles I write are from the perspective of beginners. Whether it is some experience or a technical article written by myself, I can make you understand it, and it is very easy to read, and these are Contributed articles do not have;


So, I have reflected, and I will try to take as much time as possible to write original articles for you in the future, but to tell the truth, I am already working very hard. It is very difficult to completely give up the submission and write original articles by myself, so I can only take as much time as possible. Write something out. Writing is easy, everyone can open a public account and write by themselves, but insisting on updating every day is too damn hard, the only thing that keeps me motivated to keep going is your appreciation and ad click support, let’s be realistic , the only motivation in this world that can make you insist on doing something seriously is probably the reward. I don’t want to lie to you that I do technology sharing alone for the sake of feelings, and feelings cannot be eaten as food, please understand!




Today's article is also because many people have recently left me a message saying "Brother Zhang, now I have contacted the open source community and found many open source projects, but I don't know how to choose to apply it to my own project?"


This question is relatively good. I believe that many people have such questions. Let me tell you in detail.


What is open source?


"Open source" is a simplified translation from the English "Open Source". In fact, it means open source. We know that all software is written by code and compiled into a system or application. And once you open it up, it means that anyone and any organization can use your code or software, and of course you can contribute code to you for free to optimize your application. Open source means the right to choose freely, and freedom of choice means to stimulate more innovative energy. Linux is the most famous open source operating system, and Java and Android are also open source.


open source community


The open source community has developed very rapidly in the past two years. Some giants are vying to join the open source community. Some regulars such as Google, Facebook, and Square have contributed a lot of high-quality projects to the open source community. Surprisingly, even Apple, Microsoft and other relatively closed companies They are also competing to join the open source community. I have to say that this is a good phenomenon. Open source may be the future of software.


When it comes to the open source community, there is no doubt that GitHub is the largest and most popular open source community at present. The world's best programmers and the most open and excellent technology companies are all in GitHub. Why don't you join in? All open source projects mentioned in this article refer to open source projects on GitHub.


Why use open source projects?


There has always been a principle in the field of software development: DRY, Don't repeat yourself, which translates as "don't repeat the wheel". The main purpose of open source projects is to share, in fact, it is to prevent people from repeating the creation of wheels, especially in a rapidly developing field such as the Internet, where speed is life, introducing open source projects can save a lot of manpower and time, and greatly accelerate business development. Speed, why not?


Risks of Open Source Projects


Open source projects save us a lot of manpower and time, but open source projects are not perfect. I believe that people who have used open source projects have stepped on some pits, such as irregular code, bugs in the project, etc. Any problem will have a big impact on our project and the company. At this time, how to choose an open source project becomes very important.


How to choose an open source project?


The following is a more detailed description with an example. Suppose we urgently need an http network request library to use in the project. If it is me, then I will definitely search for "android + http" on GitHub as a keyword.


1. Stars


Generally speaking, I will give priority to sorting according to Stars. A high number of Stars does not necessarily mean that it is the best, but at least it means that it is quite popular, otherwise there will not be so many people who are Stars. You must know that getting a Star on GitHub is far better than getting a Star on GitHub. It is much harder to get a "compliment" on WeChat. So the search results above the fold are as follows:




The above 4 network libraries appear in the order of Stars on the first screen. Everyone should be familiar with them, but how to choose these 4 network libraries?


2. Author influence


There are quite a lot of stars, so I will definitely give priority to the influence of the author. Influential people are not necessarily the best choice, but at least it means that it is not unreliable. If the author is familiar to you, then Better to do it. The first two of the four are produced by Square, and the last two are personal works. If you are familiar with Square, you can basically make a choice here. Square is really a conscientious company in the open source world. It has made a huge contribution, even more than the open source projects contributed by Google and Facebook, and the quality is very high. The famous Android legend Jake Wharton is an employee of Square. Generally speaking, company projects take precedence over personal projects, not to mention Square, but let's also take a look at the GitHub homepages of the other two authors.




The author loopj has more than 2k followers, and several of his own open source projects have quite a lot of Stars. This year's GitHub submissions are not particularly active, but they are okay. Generally speaking, he is an open source author with great influence.




The author wyouflf has 1k followers, and the number of influential open source projects is xUtils, and xUtils seems to have the latest version of xUtils3. There have been no submissions on GitHub in the past year, indicating that it is not particularly active.


So overall conclusion: Square > loopj > wyouflf


3. README.md


The above only analyzes some of the most basic external factors, but we still need to look at the specific documentation about the project, whether it is a function introduction or a method of use, which are all introduced in README.md.


After reading the documentation and introduction of these four projects, they are quite complete and detailed. We have a preliminary understanding of the basic functions of each library:


  • Retrofit and OkHttp are http network libraries for Java and Android;

  • android-async-http is an http network library specifically for the Android platform;

  • xUtils is a complete set of frameworks for the Android platform, it includes several functions of orm, bitmap, http, view inject;


So far, for me personally, I have basically eliminated the xUtils framework. It does not mean that it is not good, because I have not yet understood the quality of each library in detail at this stage. I do not like to use this kind of "big and comprehensive" framework. One is personal habit, and the other is that the risk is high, because once one of the functions fails, it will be more troublesome for you to solve. If you want to replace it because of this problem, it will be more troublesome, unless I can be sure that this framework is very mature and easy to use. , otherwise I would prefer to choose a "focused" framework, and we mentioned at the beginning that what we need is the http network request library, so xUtils was eliminated by me.


There are three network libraries left. We also mentioned earlier that android-asyn-http is an http network library specially launched for the Android platform, while the two libraries of Square are more extensive, not only for Android, but also for the Java platform. In fact, according to my Personality (well, I prefer to be distracted), so far I will basically choose android-async-http, because I prefer "focus", in fact, I am indeed like this, the network library I first came into contact with was indeed It is android-async-http, which is really useful. But at the moment I would not choose it.


4. Last update time, Issues, Fork, etc.


Why not choose android-async-http now? The reason is that the last release time of the author of this library is September 19, 2015, which means that the author has not updated for 7 or 8 months. For an open source project, the most fearful thing is that the author does not maintain it. It means that there will be no improvement in the future, and it is difficult to solve any problems quickly.


Looking back, the xUtils project has not been updated for 2 years.


Let's take a look at Square's Retrofit and OkHttp projects that have been updating their code in recent days:




If the code is updated, it means that the author has been improving the project. In addition to the last update time, the number of Issues, the speed and proportion of the author's reply, and the number of Forks are all good reference indicators that reflect the attention and popularity of the project. .


5. Open Source Protocol


Do you think open source projects can be used casually? That's wrong. The use of open source projects must also follow certain principles, the so-called open source agreement. Common open source license agreements are:


GPL、LGPL、BSD、Apache Licence vesion 2.0、MIT。


I won't explain these agreements too much. In addition to the GPL agreement, the GPL agreement stipulates that the code using the open source library must also follow the GPL agreement, which means that it must also be open source and not suitable for commercial projects. Other agreements will have some restrictions, but the impact is not large, you can search and understand by yourself. So far, MIT should be regarded as the most used open source protocol.


In fact, there is another wonderful protocol in the open source world called the "WTF" protocol. The name of the protocol is: "DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE". If you have accidentally seen this protocol in any open source project, don't make a fuss, there is such a protocol!


6. Comprehensive


After the above analysis, OkHttp and Retrofit are the two best choices. Finally, let's take a closer look at the difference between these two libraries.


From the documentation we learned that:


OkHttp is a Java and Android platform Http request library, very efficient, supports SPDY, connection pooling, GZIP and HTTP caching. By default, OKHttp will automatically handle common network problems, such as secondary connections, SSL handshake problems.


Retrofit is a client-side implementation of Http request library for Android and Java platforms with a RESTful architecture. Based on annotations, it provides JSON to POJO (Plain Ordinary Java Object, simple Java object), POJO to JSON, network requests (POST, GET, PUT, DELETE, etc.) package.


But if your application integrates OkHttp, Retrofit will use OkHttp to handle other network layer requests by default.


So in a word, if you want to write your network requests more elegantly, it is recommended to use Retrofit, especially in combination with RxJava, otherwise it is possible to use OkHttp directly.


Are you asking what networking library our project uses? We have several projects, and the most used one is Volley, because if it is an official project launched by Google, we usually use it first. After all, the official one will not be too bad.


Summarize


The above is just an example of an Http library request to teach you how to choose an optimal open source project, and other types of open source projects are also applicable. What I want to tell you is that the choice of open source projects will never be the best. You can only choose one that is relatively mature and suitable for you under the indicators of comprehensive evaluation.


Finally, I want to remind everyone that we don’t just use open source projects, especially for commercial projects. It must be a relatively mature project, and you have already understood its principles and feel that you can control it. It is used in commercial projects, otherwise it will cause great risks. You must know that business and stability are the first, and you must always learn to control risks!


There is no best, only fit!



WeChat does not support external links. You can click "Read the original text" to view it. If you feel it is helpful, you may wish to forward it and support it. Press and hold the QR code to subscribe.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324063846&siteId=291194637