Tools and ways to understand object-oriented code
In my work / study, I have had to look at, understand, and modify non-trivial code written in an object-oriented style, with little documentation. For my case these are architectural simulators in C++.
I would like to know from more experienced people about what are some of the more efficient ways to look at and understand an existing project. This is an open-ended question, and maybe I am not being able to express properly what I mean, but this is an important issue for me. Every time I have to modify a simulator or some other tool, I spend quite a lot of time struggling with understanding the flow. I am trying to make this process more efficient and less time-consuming.
Are there tools that can take a code base and generate a useful diagram representation like UML diagrams? Also are 开发者_Go百科there any specific techniques that has been useful to you while analyzing code?
On of the possibilities you have is doxygen
This Wikipedia page gives a decent list of tools that you may find helpful. I'm fond of cpplint, myself.
If I was in your situation the first thing I would do would be to attempt to track down the original author. The author will have a far better understanding of the code than what you could get from just reading the (hypothetical) comments.
If the original author cannot be found then the answer depends on what you want to do with the code.
If you want to add some code, then your best bet is to sit down and force yourself to understand the structure of the design. If you do not, then any code that you add is likely to fit very poorly into the overall structure.
To understand the design you will need to read a lot of code. I do not think there is an easy way around it (unless the code is unusually well designed and structured). As you read more code the code that you have not read will become easier to understand. You will be able to reuse you understanding of the components and patterns used in the design to quickly understand what a particular part is doing.
Good Luck!
精彩评论