How to view a large program code

Source: Internet
Author: User

1. quickly understand the basic knowledge and background of the entire code

2. If the program is a installable or runable program, install and run it to understand its functions.

3. The modules are divided by function. The modules are modular and small modules. The major problems are solved one by one.

4. You 'd better figure out several lines in a certain way and follow these lines step by step.

5. Use a better code reading tool. Here I recommend that source insight use this tool to easily track data structures and classes.

6. Clarify the function call methods and use source insight to find out the function call process.

7. The key data structures and inheritance derivation of classes should draw a graph that you can understand, so that you can modify the graph at any time while viewing the code, which is also easy for you to understand.

8. Large code definitions can be divided into several modules.

9. Let's look at a function first to view its return value and input parameters, and then to see what the function has done, what the parameter brings in, and what the return value or reference takes away.

10. Look at the code in a computer's way of thinking, and summarize the code in a human's way of thinking. Do not look at the language and syntax in one-sidedness, so you do not know what the program is for after reading it.

11. After you have understood the code, it is best to make a detailed comment on the Code side. When you come back later or use the code, you will find that the comment is too useful.

12. The special mechanism used in the code should be clarified. For example, to view the socket, you must understand the select, poll, and epoll mechanisms. You can check other materials to see these event mechanisms.

13. After reading the code, I can tell in my own language what this is and how it is done. Then I can see the code at a level.

14. it is very important to look at struct or classes. First, we should combine them to find out what the variables defined by the struct are used for code search, where the struct has been called, and how to create it, how to delete, initialize, and use

Have a general understanding of struct

15. Reading a struct or function reference is very important to help you understand the role of this struct in code,

 

Note:

In the first step, quick browsing must be fast and cannot be entangled in a small problem. It is best to grasp and understand this step from the overall macro perspective.

The second step is to understand functional things with bold guesses and be careful with verification.

The third step is to take a closer look at a specific functional module. If you want to go deeper, you must really understand it. If you want to go deeper, you must go deeper into some data trends or ideas, instead of in-depth syntax and language

Step 4: Walk along several lines, so it is not easy to get lost. When you look at the code, it will not be dizzy ---------- it is best to draw a picture of the initialization and destruction of the data structure code to look good, let's look at the operational code again.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.