Like others, I say this is a slow process.
However, having done this many times in the past, this is my methodology:
Define as many requirements that the code fulfills. This may give you some reasons why some things are what they are when you look deeper. A common way to find them is to search for any available tests. Automatic is best, but usually they are as absent as comments.
Find code entry points. This will give you places where you can push the code to see how different inputs affect the stream. Common entry points are the "Basic" code input functions, service interfaces, backlinks to web pages, etc.
Draw the code. Check out the tools that can create black and white snapshots of code. For me it is priceless. Sometimes I printed large lists and then attacked with bullets and rulers. You are aimed at creating your own flowchart (mental or otherwise) of the code stream.
Using the above (iteratively) create a set of outputs for the code that you think should happen, and add outputs to them that you may already know about, such as logs, data files, records in the database, etc. .
Finally, if you have time, create some manual tests, although preferably in automatic test harnesses, to test this. This is when I start attracting a debugger to see the details in the code.
This technique usually gives me confidence in making changes.
Please note that this is an iterative process and may be performed with parts of the code or as a whole at your discretion. I usually prefer a top-down approach, and then when I get some information, I turn around until the details become overwhelming, and then repeat. However, this is only because my mind works in this way - you can be different. Good luck.
Preet sangha
source share