C++ function dependency graph

c++, graph

Solution

First level of modularization - and I hope you already have done that - is structuring your code in classes. If your code is merely a collection of functions - i.e., C plus some syntactic suggar - then it's high time to rewrite your code, because no amount of dependency-graph-building will save you from maintenance hell.

If you have classes, modularizing should be a matter of finding classes that closely work together (like `Customer`, `Order` and `Invoice`) and separate them from classes that are only losely coupled with them (like `Employer` or `Facility`). Then take it from there.

Modularizing code is something that requires, first and foremost, thought. No automatic procedure is a replacement for that. Actually, from what little you wrote, I would fear that any automated process would make things worse, because apparently there has been too little thought invested in this project already. I.e., you wrote 1 million lines of code without thinking about modularization, and now you want modularization to happen while still not actually thinking about it. You are heading for epic fail.

Problem

Possible Duplicate: C++ code dependency / call-graph “viewer”? I am working on a huge C++ code base and currently I am stuck with the problem of modularizing my code. I have to divide my code into separate independent modules. One approach I can think of is to generate the dependency graph and then do a higher level categorization. Other approach is to start with a entry point (some function `abc()`) and generating a function call tree whose each node will contain the name of the file in which that function resides. Thereafter I can use some script to extract those functions into separate modules. My question is, is there any tool that can help me do this task? Has anybody faced such a problem earlier. Or can you suggest any approach to achieve the same?

Original source

Related problems