• Have some understanding of related technical knowledge

    How to Read

    1. Choose the correct version to read.

    Open source code, after many years of accumulation, the author start with a single function, then often contain too many features and use of the tip, if you are not very familiar with the beginning, you may will be meng at the first glance, but if you are from the original release code, or you will be able to understand the distribution of and began to read, read back with this version, You get the feeling that it wasn’t so hard to build a wheel. I especially recommend this article, which I also referred to in the initial reading process. How to read open source software code in the “right posture”

    2. With demo, log when appropriate

    Demo

    Every open source project should provide a Demo, which usually contains some common usage, or a brief introduction of some usage; With the Demo you can at least once again see the project and what problems it uses and solves. Some demos may not work, and you need to use your existing knowledge to solve the problem, often in the process of solving the problem you will have some additional discovery and understanding.

    Log

    Logs are print markers that you use to test or debug code, and combining logs with breakpoints gives you an accurate idea of how long your code takes and in what order it executes. Log tells you when to call, breakpoints can see what functions are called after breakpoints, and knowing when to call them helps us understand our code.

    3. Don’t get bogged down in details the first time

    Most of the time you will be entangled with small clever implementation in your code, and then hold up a lot of time in the process of struggle, so often leads to low efficiency, and easy to cause fatigue reading, so it is better the first time to read just know, be able to understand the whole structure or frame design is better, if you can draw the auxiliary figure is better, There is no need to delve into the specifics.

    4. Look at the implementation with an understanding of the overall architecture

    Practice makes perfect. Unless you have a genius for coding and want to understand the whole open source project in one reading, you have to go through it again, this time carefully, and then look at the implementation against the auxiliary drawings you have drawn.

    5. Break down large modules into smaller ones

    In fact, most separate source code has a common feature, modular, a small module often only achieve one or two functions, so this is divided into small modules look faster to understand, but also easier to let you clearly understand. And if you always look at the code as a whole, as a system, you tend to mess with your brain, and it just becomes inefficient, and you forget it.

    6. Write your own implementation as you read

    A good memory is not as good as a bad pen. If you just read it, you will forget it quickly, and reading open source code is not easy to understand all at once. This is when you need to implement it based on your own understanding. Or better yet, you can approach it in a different way.

    7. Don’t put too much faith in code parsing written by others online

    A lot of other people’s code parsing, are all very good, but these were probably what others after digestion, he can understand how much I said is not clear, you may be very deep, also may be shallow, may also be understanding deviation, if you blindly believe in, and to explore the code for you may also have a wrong understanding, In addition, you have absorbed and digested a little from the author, so you still don’t understand. Maybe when others communicate with others, you can say something, but you still don’t understand deeply.

    8. Use search

    If you have a problem reading, go ahead and search. If you Google, all your problems will probably come up, but if you don’t, you can still email the author.