Slashdot Mirror


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."

13 of 67 comments (clear)

  1. Source Navigator by IYagami · · Score: 5, Informative

    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.

  2. Doxygen by Tersevs · · Score: 3, Informative

    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.

  3. Doxygen for C++ / C etc by ssclift · · Score: 3, Informative

    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.

  4. Doxygen by DeadMeat+(TM) · · Score: 4, Informative
    Doxygen can use Graphviz to generate class and call graphs for several different languages. It helps to have Doxygen or Javadoc annotations in the code, but it's not necessary.

    Unfortunately graph generation is pretty slow, but otherwise it's a fantastic tool.

  5. Meh by cookiepus · · Score: 3, Insightful

    If your codebase is anything like what I've been working with, there's no tools that are going to make your life easier.

    If the code had decent structure, you'd not be asking this question. But it's a mess. And if you display the mess as a tree structure, it's still a mess. The value is limited.

    The best thing I've done is set up etags accross the entire codebase. This way I can at least navigate code easier. But I doubt you will understand anything more from tree graphs.

    1. Re:Meh by _flan · · Score: 3, Interesting

      I don't think that's entirely a fair statement. I find that being able to visualize a codebase can help significantly -- even when it is a mess.

      Where I work we have some home-grown (and not terribly good) tools that help us visualise a project's architecture, from both the design and the implementation point of view. For projects that are good, these two views mesh perfectly. For projects that are crap, they diverge wildly. This gives a you a good idea where a little refactoring might to a lot of good. When working on a new code base, I start like this -- making small, incremental changes, documenting places that I find difficult to understand, and above all talking with more experienced developers.

      Also, as someone that hates to write documentation, I find it invaluable when trying to describe large systems. But my documentation always has pictures, because they are fundamentally easier to grasp quickly than ten dense pages of text. Unfortunately, it's difficult to put good diagrams in comments.

      (As an aside, back in my university days, I worked on a project where we did all of our coding in FrameMaker. This allowed us to put in pictures, colored comments -- basically anything. The build script turned the FrameMaker file into C++ source, which then got compiled. It was kind of the extreme version of self-documenting code.)

  6. Debug by rmull · · Score: 3, Insightful

    This is perhaps a tangential answer, but I do much better by going through the code with a debugger and watching things happen. Especially with some of the more compilacated OO stuff, and when the comments are unhelpful or wrong, it can be much more useful than reading the code.

    --
    See you, space cowboy...
  7. SHriMP/Creole, JQuery by Earlybird · · Score: 3, Informative
    SHriMP (screenshot):

    • ... designed for visualizing and exploring software architecture and any other information space. SHriMP (Simple Hierarchical Multi-Perspective) is a domain-independent visualization technique designed to enhance how people browse and explore complex information spaces. Among the applications we are actively exploring is the exploration of large software programs, and the understanding of complex knowledge-bases (via the Protégé 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.

  8. Literate programming by keramida · · Score: 3, Interesting
    As an aside, back in my university days, I worked on a project where we did all of our coding in FrameMaker. This allowed us to put in pictures, colored comments -- basically anything. The build script turned the FrameMaker file into C++ source, which then got compiled. It was kind of the extreme version of self-documenting code.

    This sounds a lot like a relatively old, but intriguing idea. "Literate Programming" is exactly what you describe.

    It is exciting to write heavily documented code, but I doubt it can be done after the fact :-/

    --
    My other computer runs FreeBSD too.
  9. For PHP try this... by todsandberg · · Score: 4, Informative

    PHPXRef: PHP Cross Referencing Documentation Generator
    http://phpxref.sourceforge.net/

  10. lxr by hitchhacker · · Score: 3, Informative


    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

  11. It takes a *long* time to learn large systems. by Richard+Steiner · · Score: 3, Insightful

    I worked on the flight operations system for a large airline for over eight years (actually ten if you count my contractor time), and I only learned the intimate details of perhaps 20% of it bu the time I'd left.

    Complex applications require a huge amount of specialized knowledge in order to understand, and most of that knowledge relates to the application or work process itself, not the technical environment...

    --
    Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
    The Theorem Theorem: If If, Then Then.
  12. Cscope by Anonymous Coward · · Score: 3, Informative

    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.