How to read the source code?

"how can an inexperienced junior programmer with poor skills read the project source code?"

"has anyone read the source code of mybatis? just look at the initialization process and get dizzy. Friends, give me some advice!"

"how to read the source code? I have tried to read some source code, such as the sqlparser part of the druid of alibaba, but spring-mvc, found it very difficult. They all say that debug is the best way to read. I often lose track of it when I am in debug. It is just that walking feels like I have entered some details that I don"t pay much attention to at present."

.

it is estimated that many people have such doubts.

I can understand the pain of my friends very much, because I have come here in the same pain.

the benefits of reading excellent source code must be known to all, learning other people"s excellent design, reasonable abstraction, concise code. In short, there are a lot of benefits.

but really put a huge code in front of you, just like a huge maze, it is really not easy to find a way to turn west in the Middle East to figure out the whole structure of the maze and understand the core ideas.

when reading code written by object-oriented languages such as Java, you will find that interfaces often do not correspond to specific implementations, and it is not clear exactly how a function can be found in which implementation class. Unlike the C language, it is a function to call a function, which is relatively good.

if it is a dynamic language such as Ruby,Python, the type of a variable is not even easy to know, which makes it much more difficult to read.

there is another important reason. Now the source code we see is basically developed for several years and constantly improved by many people. There are so many branches and vines that the devil is in the details. When reading, it is easy to fall into it. After watching dozens of layers of function calls, I am completely confused and give up: no matter you blow up the source code, I will never look at it again.

Feb.28,2021

I'm not a senior programmer, but I'd like to share my experience a little bit.

< H2 > A well-structured project < / H2 >
  1. find a suitable source code reader / editor / IDE; as much as possible
  2. if the project uses a framework, learn about it first;
  3. find the entry to the project (if any) and skim through it;
  4. imagine a usage scenario, human flesh step debugging (or debugger step debugging if you can), understand what the outermost step of the project has done (you don't need to know how to implement it), and draw sketches if necessary to deepen your understanding of the flow and structure of the program. you can skip what you don't understand, but skipping this step will not affect your understanding of the whole. After you have almost understood it, you can move on to the next step ;
  5. .
  6. go back to the previous step, but each step requires "step into" to go deep into the project, and if there is something you don't understand in the previous step, try to find the answer in the in-depth process. Sometimes the hole dug in the outer layer will be filled in the inner layer.

it's almost purple

< H2 > A messy project < / H2 >
  1. find a suitable source code reader / editor / IDE; as much as possible
  2. put aside the source code, sort out the requirements and functions of the project, and think about how you would achieve it if you wanted to achieve it.
  3. try the steps in "A well-structured project" and pray that the author's idea is the same as yours.
< H2 > GCC < / H2 >

if you are looking at the GCC source code, forget it.

I glanced at the GCC source code and even tried to clone them down.

if one's skills are not as good as others, he is willing to be outdone.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8a8de-fe4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8a8de-fe4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?