The method and experience of reading the source code of open source projects

For more open source projects, please check: A list focusing on recommending .Net open source projects

I have written 6 consecutive articles in the column of "EF Source Code Analysis" in Knowledge Planet: Learning Small Circles. Today, I will share with you the experience and experience of reading the source code of open source projects .

picture

Mindset is very important

Many people are most concerned about how to read the source code of open source projects. Many fans and friends feel that it is very difficult, and they flinch when they see the code. In fact, this is very normal. It is the same for old programmers like me . , Impetuous, these are the reactions of normal people, at least I am like this.

So the mentality of reading the source code is very important, especially when you first start, you can’t understand many places. At this time, you have to tell yourself not to give up, bit by bit. After you get started, you can read it slowly and easily. , you will no longer feel crazy and impetuous.

So when reading the source code, patience is very important, you can't give up easily, you can give yourself a little more time, read slowly, and after you get started, you will be fine.

Basic knowledge is key

Reading the source code, many people can’t understand it. This has a lot to do with their own knowledge reserves. For example, EF has application design patterns, event delegation, extensions, records, etc. Many people will not understand without this knowledge. This is very normal. As an old programmer, I will also encounter such problems. Some new features of C#, or some features that are rarely used in general, I will also see them because I haven’t learned them or forgotten them. don't know.

Encountering such a problem is not a big problem. You only need to learn the corresponding knowledge points first, and then continue reading after learning the new knowledge points. Another advantage of this is to supplement your own knowledge points. In addition, you can A deeper understanding of the use of knowledge points and why the author adopts such a design.

Learn from others first

Before reading an open source project, you can first understand its background, how to use it, and search for other people's related sharing on the Internet. **Now there are a lot of learning materials on the Internet. Popular open source projects are basically shared by other bloggers. You can read their sharing first, and then read the open source projects, so that it is easier to get started.

Start with unit tests

Every mature open source project has a unit test, just like the EF project, each function point has a corresponding unit test, we can start with the unit test, understand each function point, and find the function relatively quickly Click the corresponding source code.

reward

Excellent open source projects are written by a group of extremely talented programmers. In addition, open source projects need to consider versatility. Their considerations are very comprehensive, so the codes they design are also relatively excellent codes. When we learn the code of open source projects, we can harvest their design ideas.

In order to understand their design ideas more easily, you can first think about the problems they need to solve, the user groups they are targeting, and the relevant background, so that you can understand their design ideas more deeply and easily.

In addition , open source projects have many and comprehensive considerations, many of which we will never encounter in actual project development, so reading open source projects is equivalent to our experience, which is also very helpful for us to learn programming Yes , if you encounter similar problems in project development in the future, you can use it immediately.

at last

It is highly recommended that you try to read the code of open source projects. After all, it is a group of old programmers who have thoughtfully designed the code. We can learn a lot of knowledge from it, and it can also cultivate our good learning habits.

- End -

Welcome to join the learning circle , get massive programming learning resources and learning routes, check in with everyone, share programming knowledge, and make progress together.

recommended reading

A simple, fully functional WMS warehouse management system

Annual inventory of 10 most popular .Net open source projects

Recommend a cross-platform operation library that supports more than 30 formats such as Word, Excel, CSV, Email, etc.

A simple and easy-to-use configuration file manipulation library for .Net

A list focusing on recommending .Net open source projects

Guess you like

Origin blog.csdn.net/daremeself/article/details/128892758