Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The best way to explore/investigate/understand class hierarchy and principle of work of new project

Imagine such situation. You get some legacy code or get some new framework. You need to investigate and understand how to work with this code as soon as possible. There is no chance to ask for help from previous developer. What are the best practices/methods/ways/steps/tools (preferred .NET Framework tools stack) to use to get maximum efficiency in investigating new to you code base.

If it is framework and there is no much documentation and unit tests, what tools you usually use to explore class hierarchy, methods, events? Is it default Object Browser, Architecture Explorer of MS Visual Studio or some other tools like Resharper hierarchy/file view?

like image 678
Dao Avatar asked Oct 13 '22 20:10

Dao


2 Answers

There really isn't a best way to do this as there are so many variables and every project is different from the next.

To be absolutely honest the best way to get your head around it is to create a sandpit/test environment and, for want of a better description, play with it. Then play with it some more.

As an example of 'playing with it', using debugger and stepping through the code will tell you a lot about the flow and structure of the code. It is also worth mentioning that you should never trust comments, verify functionality yourself. Code may have changed since a comment was written.

like image 95
MrEyes Avatar answered Nov 15 '22 10:11

MrEyes


The best way for diving into a new application with a large code base, the best solution that I've found is to get big picture of it through reverse engineering facility in applications like Enterprise Architect or so. If it's not available to you, try class diagram provided by VS.

So far you can get the static definition of program , but for understanding the flow of execution follow the main scenarios execution path by facilities that you mat find in Resharper, VS2008(generate sequence diagrams, and ...) and VS2010(view call hierarchy and ...).

As said in previous answers debugging and profiling applications is also very helpful, set breakpoints, look at call stack, watch the objects and ....

like image 28
Jahan Zinedine Avatar answered Nov 15 '22 09:11

Jahan Zinedine