Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
How do you dive into large code bases?

Sometimes before developing new products we need to understand some existing products or existing source code.

Sometimes to write another small module of that big project we need to understand that big source code.

In our case we need to study and understand a project with lots of files and folders. What is the easiest and most comfortable way to do it ? (especially for C and C++ and under Linux)

share|improve this question

migrated from stackoverflow.com Oct 18 '11 at 6:23

This question came from our site for professional and enthusiast programmers.

marked as duplicate by ChrisF Oct 18 '11 at 9:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Chris F: it would really have helped if you linked to the “exact duplicate” you are referring to. Ugh. –  veryfoolish Oct 22 '11 at 3:22
add comment

5 Answers

All big projects have some sort of documentation usually Doxygen which can help a lot in understanding the code.

You can also use code browsing tools like SourceInsight to study the code.

Last but the best approach is run the code and debug use cases.

share|improve this answer
add comment

Als have already mentioned Doxygen which is used for documentation in many projects.
For source browsing: vim along with plugins, cscope & ctags work very well. These can be installed easily on Linux environment and work very well in tandem.
Hope this helps!

share|improve this answer
    
+1 for vim/cscope/ctags - I would be lost without these when I jump onto big, new projects (although cscope - at least the version I'm using - seems to struggle with some aspects of C++) –  Radian Oct 19 '11 at 17:58
add comment

There are different approaches. Documentation if present should help, but in the real world sadly there are quite a few poorly documented code bases. In many cases you can ask some senior developer in the company for guidance, make sure to ask for some high level view of what and how are things done in each module.

You can use a UML analysis tool to extract information from the code base, I suggest BoUML, it is not pretty, but it does a good job at processing C++, and you can create class diagrams by just pulling one class and expanding from there.

An IDE or a similar set of tools that help you navigate through code will also help, as they will allow you to navigate through code much easier than with a plain editor.

While doing the analysis, make sure that you take notes on what you believe each part of the code does, or where you have doubts, then ask a senior in the company to confirm your understandings or to fill in the gaps.

share|improve this answer
add comment

While reading and documentation can be helpful, writing helps too!

Write some tests (nothing serious) which use common features of the codebase, or focus on the components you will need to use.

Try to document some of the things you did not expect, issues you had, and deviations from your team's practices.

You may be surprised by how some programs operate, and how they are expected to be used.

share|improve this answer
add comment

You just need hard work.

Getting familiar with a large codebase is like disentangle a skein. You start somewhere, understand nothing. Then start again elsewhere, still understand nothing.

Start after start, some parts get less obscure. Starting again where you started the first time now provides some clues.

Then the strategy is divide and conquer. Isolate modules and understand them one after the other.

Possible starts are: Makefiles, main() function, file hierarchy, existing documentation (at least a README file) or whatever Doxygen is able to extract even if it was not planned.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.