The best way to familiarize yourself with an inherited codebase

后端 未结 14 1437
[愿得一人]
[愿得一人] 2021-01-30 02:54

Stacker Nobody asked about the most shocking thing new programmers find as they enter the field.

Very high on the list, is the impact of inheriting a codebase with which

14条回答
  •  遥遥无期
    2021-01-30 03:14

    My steps would be:

    1.) Setup a source insight( or any good source code browser you use) workspace/project with all the source, header files, in the code base. Browsly at a higher level from the top most function(main) to lowermost function. During this code browsing, keep making notes on a paper/or a word document tracing the flow of the function calls. Do not get into function implementation nitti-gritties in this step, keep that for a later iterations. In this step keep track of what arguments are passed on to functions, return values, how the arguments that are passed to functions are initialized how the value of those arguments set modified, how the return values are used ?

    2.) After one iteration of step 1.) after which you have some level of code and data structures used in the code base, setup a MSVC (or any other relevant compiler project according to the programming language of the code base), compile the code, execute with a valid test case, and single step through the code again from main till the last level of function. In between the function calls keep moting the values of variables passed, returned, various code paths taken, various code paths avoided, etc.

    3.) Keep repeating 1.) and 2.) in iteratively till you are comfortable up to a point that you can change some code/add some code/find a bug in exisitng code/fix the bug!

    -AD

提交回复
热议问题