tags:

views:

188

answers:

4

Hi,

I'm a student who's learning C++ at school now. We are using Dev-C++ to make little, short exercises. Sometimes I find it hard to know where I made a mistake or what's really happing in the program. Our teacher taught us to make drawings. They can be useful when working with Linked Lists and Pointers but sometimes my drawing itself is wrong.

(example of a drawing that visualizes a linked list: nl.wikibooks.org/wiki/Bestand:GelinkteLijst.png )

Is there any software that could interpret my C++ code/program and visualize it (making the drawings for me)? I found this: link text

other links: cs.ru.ac.za/research/g05v0090/images/screen1.png and cs.ru.ac.za/research/g05v0090/index.html

That looks like what I need but is not available for any download. I tried to contact that person but got no answer.

Does anybody know such software? Could be useful for other students also I guess...

Kind regards,

juFo

A: 

Doxygen has, if I recall, a basic form of this but it's really only a minor feature of a much bigger library, so that may be overkill for what you want. (Though it's a great program for documentation!)

Toji
Doxygen actually has very impressive visualization tools. It can generate comprehesive call graphs, caller graphs, inheritance graphs, and has one of the most complete C++ parsers available (it's actually better than MSVC's!)
coppro
Very nice! They must have improved it since I last looked.
Toji
+2  A: 

Have a look at DDD. It is a graphical front-end for debuggers.

Try debuggers in general to understand what your program is doing, they can walk you through your code step-by-step.

Juri Glass
+5  A: 

This is unrelated to the actual title but I'd like to make a simple suggestion concerning how to understand what's happening in the program.

I don't know if you've looked at a debugger but it's a great tool that can definitely vastly improve your understanding of what's going on. Depending on your IDE, it'll have more or less features, some of them should include:

  • seeing the current call stack (allows you to understand what function is calling what)
  • seeing the current accessible variables along with their values
  • allowing you to walk step by step and see how each value changes
  • and many, many more.

So I'd advise you to spend some time learning all about the particular debugger for your IDE, and start to use all of these features. There's sometimes a lot more stuff then simply clicking on Next. Some things may include dynamic code evaluation, going back in time, etc.

JRL
I found this on wikipedia: http://en.wikipedia.org/wiki/List_%28C%2B%2B%29#List_VisualizationIs this automatically created by a program or just drawn by hand? If it's automatically: what software is used there?
juFo
@juFo: that's just a diagram done manually to illustrate a linked-list.
JRL
A: 

Reverse engineering the code to some sort of diagram, will have limited benefit IMO. A better approach to understanding program flow is to step the code in the debugger. If you don't yet use a debugger, you should; it is the more appropriate tool for this particular problem.

Reverse engineering code to diagrams is useful when reusing or maintaining undocumented or poorly documented legacy code, but it seldom exposes the design intent of the code, since it lacks the abstraction that you would use if you were designing the code. You should not have to resort to such things on new code you have just written yourself! Moreover, tools that do this even moderately well are expensive.

Should you be thinking you can avoid design, and just hand in an automatically generated diagram, don't. It will be more than obvious that it is an automatically generated diagram!

Clifford