当前位置:网站首页>How programmers learn open source projects, this article tells you
How programmers learn open source projects, this article tells you
2022-07-31 17:47:00 【Zhang Yong】
Programmer work a few years classmate,有了一定的项目经验,For programming also had his own understanding,But they sometimes confused,I don't know how to improve their next.
在笔者看来:"Programmers need most at this stage is to raise their programming ability and vision height,Open source projects and learning is one of the most effective ways to".
这篇文章,The author talk about their own learning the experience of open source projects,希望对你有所帮助.
1 学会使用
首先,我们需要学习如何使用开源项目.
Github Is the world's largest online software source code escrow service platform,Many open source projects are managed on him.
在 GIthub 下载源码后,Need to focus on the similar Quick Start,Getting started ,Example 之类的文档,These documents show beginners how to use the project.
If the project need to deploy,Reference project documents,在独立的环境中,Try to start from scratch,To deploy the project.
Some projects will also provide the perfect example 工程·,There is a ready-made examples,Can try to run introduce according to document entry example.
If entry example running smoothly ,For project for beginners is a good start.If in the operation of the abnormal,Don't panic,Looking for projects FAQ 文档,Problems or search keyword(Such as abnormal information),Query related solutions.
Successfully run the program after the first base case,Can try to run more complex function example.
笔者建议Create a project alone,One example complete the whole project.When the project is more and more plentiful,Also it shows that the more you master.在学习过程中,Record the experience of learning in the notes,To facilitate subsequent back.
2 阅读源码
Read the source code is the most important step to understand the open source project.
阅读源码之前,Try to build the project from source.Open source projects usually provide a build guide,To guide you how to set up one for the develop、Debugging and build environment.构建成功后,Try to run the project.
See the project's architecture design document,Teasing out the whole project skeleton,You can draw flowcharts or UML 图,To deepen the understanding of project.
When we know that the whole project skeleton,Can choose interested in module to read,For example, if you are interested in network communication,Just read the network layer code,Go deep into the implementation details,Such as what it used the library,What the design pattern,Why do etc.如果可以,DEBUG 细节代码.
阅读源码的时候,Attaches great importance to the unit test,Try to run the unit test,Basically a good unit test function and boundary description of the code will be clear.
The author systematism reading the source code is in2014年.彼时,RocketMQ 3.0 刚开源不久,The author of the message queue is extremely interested in,At the same time also urgently want to know about network programming framework Netty 到底是如何使用的.
于是,先从 RocketMQ 网络通讯模块 remoting 开始学习,Because the source of the perfect test case,To run the unit tests first,Learning network coding model.
In the process of learning network programming,I have two breakthrough thinking:
▍一、Client-side programming model
RocketMQ The client network communication has the following three ways:
oneway : 单向发送
sync :同步调用
callback :异步回调
Many technical thinking is mutually,Below is the ant open source components of communication sofa-bolt Support the type of call.

▍二、The server processor mode
RocketMQ Server communication using classic Reactor 模式 ,Server register different business processor,And each business processor can bind different thread pool.
void registerProcessor(
final int requestCode,
final NettyRequestProcessor processor,
final ExecutorService executor);

Learned network framework Remoting 之后,然后结合 Broker 模块,学习 RocketMQ 存储模型,In this way can RocketMQ 有了一个相对清晰的认识.
3 知行合一
I had just graduated from university,Kai-fu lee teacher's reading,书中有一句话,我印象深刻: “I Hear and I Forget, I See and I Remember, I Do and I Understand ” .
The ancient Chinese philosopher xunzi also said:"不闻不若闻之,闻之不若见之,见之不若知之,知之不若行之;学至于行之而止矣".
学习源码的过程中,The knowledge to consolidate the key gist is动手实践,And to ensure that after practice输出产物,也就是知行合一.
The author summarizes the experience at two o 'clock,供大家参考.
▍一、The key points in the source code is applied to the project
Open source projects have very much优秀实践 ,The coding skills in code can be,设计思想,Good source to introduce into the business project.
2014年,Elong coupons computing services meet performance bottlenecks,The author is responsible for reconstructing the system. 在阅读 RocketMQ 源码后,Learning to the thread pool using the essence:线程池隔离,各司其职 .
于是,The author first create the business scenario,根据任务类型,The binding of different thread pool,To facilitate the extension configuration parameters of external exposure of concurrent degree.In the process of reconstructing the system of,还引入 RocketMQ Create a thread tools code .
重构之后,The performance of the system not only improved the5倍,And the author's confidence is greatly improve,The understanding of technology is also more deep.
▍ 二、造轮子
When we learn a open source project,We can refer to open source copy write a.Copy the process of writing is the process of check are missing,Also can improve their own knowledge system.
2016年,sharding-jdbc 开源了,Below is the sharding-jdbc 的架构设计图:

I was crazy about depots table,Mind at the same time there are a lot of questions,Such as how to encapsulate jdbc 的接口,如何实现 SQL 解析 ,The results of how the shards polymerization, etc.
于是,笔者参考 sharding-jdbc 的源码,Imitation wrote a depots table component.

After this verse,The author further practice client The principle of pattern depots table,And accumulated technical reserve.
4 参与开源
“One of the open source concept is very encouraging of different people work together”.——Linux 之父
Linus Torvalds
2016 年 2 月 TED 演讲《The mind behind Linux (opens new window)》
在《Professors encourage students to participate in the open source project 5 个理由》这篇文章里,Mentions the following five reasons:
Borderless learning Professional communication External chance A thorough understanding of computer science 玩
So the programmer how to participate in the open source ?Participate in the open source there are many ways to,最常见的有如下几种:
直接参与开源项目的开发 Refer to the open source project community game 修复开源项目中的 Bug Open source project documentation Participate in open source projects test and Demo 编写工作 参与开源项目推广
参与一个开源项目,And with so many clever same engineer,The ideas in the mind to realize,那是多么美好的事情.
5 写到最后
When you don't know choose which an open source project began to learn,希望你立足当下,行动起来.The current technical team to use open source components,It is your learning direction.
行动起来,You will become a better yourself,加油.
如果我的文章对你有所帮助,还请帮忙点赞、在看、转发一下,你的支持会激励我输出更高质量的文章,非常感谢!

边栏推荐
猜你喜欢
Huawei's top engineers lasted nine years "anecdotal stories network protocol" PDF document summary, is too strong
adb shell error error: device unauthorized
每日练习------随机产生一个1-100之间的整数,看能几次猜中。要求:猜的次数不能超过7次,每次猜完之后都要提示“大了”或者“小了”。
All-platform GPU general AI video supplementary frame super-score tutorial
MySQL---多表查询
Kotlin coroutines: continuation, continuation interceptor, scheduler
35道MySQL面试必问题图解,这样也太好理解了吧
[pytorch] pytorch automatic derivation, Tensor and Autograd
useragent在线查找
【pytorch】pytorch 自动求导、 Tensor 与 Autograd
随机推荐
华为顶级工程师历时9年总结的“趣谈网络协议”PDF文档,太强了
MySQL---sort and pagination
浅谈网络安全之算法安全
组合学笔记(六)局部有限偏序集的关联代数,Möbius反演公式
研发过程中的文档管理与工具
UserAgent 解析
基于WPF重复造轮子,写一款数据库文档管理工具(一)
学生管理系统第一天:完成登录退出操作逻辑 PyQt5 + MySQL5.8
Jiuqi ny3p series voice chip replaces the domestic solution KT148A, which is more cost-effective and has a length of 420 seconds
Kotlin coroutines: continuation, continuation interceptor, scheduler
常用的安全渗透测试工具(渗透测试工具)
淘宝/天猫获得淘口令真实url API
MySQL---单行函数
GP 6总体架构学习笔记
cas与自旋锁(轻量级锁就是自旋锁吗)
UVM RAL模型和内置seq
Taobao/Tmall get Taobao password real url API
MySQL - single function
【Yugong Series】July 2022 Go Teaching Course 022-Dictionary of Go Containers
九齐ny3p系列语音芯片替代国产方案KT148A性价比更高420秒长度