Source Code Browsers?
patonw asks: "I just started working for a company as a programmer on a project with a huge existing codebase. The person hiring me half-jokingly said that it usually takes new employees two years before they understand the system. What I am looking for is not just an editor/browser but a program that displays functions and classes as connected graphs -- preferably free. I would like to view how programs are structured by function calls and class relations. I have access to several different kinds of platforms/operating systems."
Sponsored by RedHat:
http://sourcenav.sourceforge.net/
From the FAQ:
Source-Navigator supports C, C++, Java, Tcl, [incr Tcl], FORTRAN and COBOL, and provides and SDK so that you can write your own parsers.
Use Source-Navigator to:
* Analyze how a change will effect external source modules.
* Find every place in your code where a given function is called.
* Find each file that includes a given header file.
* Use the grep tool to search for a given string in all your source files.
I havnt heard about any free source browsing programs... But I've been using Doxygen to generate HTML documentation of the source when I need to familliarize myself to new code. Definitions in the documentation will be hypertext linkes and there are class inheritance graphs generated. What's missing is really some kind of call-tree but you cant have everything. Doxygen also extract JavaDoc comments from C++ code and insert them into the HTML-documentation.
Doxygen can also generate LaTeX, and RTF files instead of HTML.
Doxygen is a good choice for C++, C, Java, Objective-C, IDL... I used it to get into a ~50K line project a few years ago and have used it regularly whenever I'm forced to use C++... Get Graphviz as well so Doxygen can draw pretty pictures for you.
Unfortunately graph generation is pretty slow, but otherwise it's a fantastic tool.
Currently SHriMP runs both as a standalone application and, using the Creole plugin, inside Eclipse to augment its existing, extensive code browsing capabilities. There's also a plugin for Protégé, a Stanford project to build "an ontology editor and a knowledge-base editor" supporting new techologies such as OWL.
While Creole is currently Java-specific, SHriMP is a generic framework for code visualization.
Doxygen does exactly what you described. See item #2 in the link.
If that doesn't work look up programs that will convert to UML. Since you didn't mention it in your question I'll expand: Unified Modeling Language diagrams are a standardized means of describing the relationships between objects in classes. To any Slashdotters out there in college looking to take a software engineering course, you'll be seeing a lot of UML.
Direct away from face when opening.
I tend to roll-my-own code analyzers because each system tends to have a different personality and there are different things to look for. Generally I try to parse the code and log each file, module, and subroutine into a relational database. Then I can query it later as needed. I also may log every variable and and token, filtering out common key-words. This risks over-indexing but is better than under-indexing becase extra tokens are less of a problem than non-indexed tokens. And, one can adjust the indexer to remove the extra ones over time. (Ideally one should parse it using perfect grammar parsers, but that is not always an option, especially with web stuff that mixes multiple languages.)
Then I log all tables and columns of the databases (data dictionary). Once all the tables, columns, variables, subroutines, and files are logged in database tables, one can cross-reference it all either batch-wise and/or using ad-hoc queries. It is just regular database stuff at that point, so one is no longer dealing with code text but SQL (but I still like FoxPro for such because of its informal nature). However, it may launch a code viewer to inspect matches.
It takes about 3-days to a week to do all this if you have done it before and know your tools, plus future tweaking to make improvements.
I have seen commercial tools that do similar things for a lot of money. But to be frank, if someone besides you will be using such a tool and they don't like using SQL, then a commercial product may have a more mature user interface. They also don't bring complaints to you when there are glitches or omissions in the parser.
Table-ized A.I.
Okay, so this doesn't answer what he was looking for, but the title reminded me of Koders... the search engine sucks, but it's a great idea.
PHPXRef: PHP Cross Referencing Documentation Generator
http://phpxref.sourceforge.net/
how about LXR?
I've been using it to browse linux source code lately: here
from the site:
A general purpose source code indexer and cross-referencer that provides web-based browsing of source code with links to the definition and usage of any identifier. Supports multiple languages.
except for lack of syntax hilighting, it works well.
-metric
Of course, that presumes that you have a decent set of functional tests that cover the code well in order to get a good idea of what is going on. Of course, the permutations involved on a moderate to large code base could be far more than you could keep in your head...
If that's too much typing for you,(without any spaces put there by Slashdot) yields: http://sourcenav.sourceforge.net/
Oh, and for you "Well just right-click on the text and click 'Follow Link'." people, tell me how to open a selected-text link containing extraneous Slashdot spaces in a new tab using Mozilla, or shut up.
Also:
how a change will effect external source modules
"affect".
I can't believe nobody has mentioned cscope yet. We used that in the multi-million line project I worked on until a couple of years ago. My division was only responsible for a few hundred thousand lines of code with a relatively well defined interface, so we generally kept our own cscope subset (Hint: cscope has an option to cache its results, and I highly recommend doing that if your project is more than a few thousand lines). I never actually had to use cscope for the entire source tree, but it worked VERY well for my area of responsibility (several tens of thousands of lines).
In order to stick to the original question, I should also mention that most nontrivial programs end up using dynamic programming styles, and there's no way to graphically display those. I also want to point out is that no source code analyzer is going to do a even a half-assed job at figuring out dynamic relationships, so if your project contains any drivers/vtables/virtual functions, then you're basically S.O.L, and you may as well just use cscope. However, if you really insist on getting a graphical output, check out the free code graphing project. It has a nice picture of the linux kernel.