C++ code visualization - c++

A sort of follow up/related question to this.
I'm trying to get a grip on a large code base that has hundreds and hundreds of classes and a large inheritance hierarchy. I want to be able to see the "main veins" of the inheritance hierarchy at a glance - not all the "peripheral" classes that only do some very specific / specialized thing. Visual Studio's "View Class Diagram" makes something that looks like a train and its sprawled horizontally across the screen and isn't very organized. You can't grok it easily.
I've just tried doxygen and graphviz but the results are .. somewhat similar to Visual Studio. I'm getting sweet looking call graphs but again too much detail for what I'm trying to get.
I need a quick way to generate the inheritance hierarchy, in some kind of collapsible view.

Why not just do it manually, it is a great learning experience when starting to work with a large code base. I usually just look at what class inherits from what, and what class contain what instances, references or pointers to other classes. Have a piece of paper next to you and get drawing...

Instead of going into the full Class Designer tool, just use the "Class View" or the "Object Browser" in Visual Studio - they present fully collapsible class heirarchies.

A good UML tool should do the trick.
Here is a list of generic UMl tools: http://en.wikipedia.org/wiki/List_of_UML_tools
There are lots out there, all with varying feature sets. Try playing with a few to see if you get the output you desire. If they free ones fail you, you might have to shell out for a good commercial grade UML tool

You can try CppDepend, it doesn't create a class hierarchy like Doxygen does but it can show 'the big picture' for your project, it also shows some code metrics.

I've had most success with valgrind and kcachegrind to do this. You run valgrind against your debugging binary, perform whatever actions your interested in, then import the output into kcachegrind to see everything you'd ever want to know about who called what, how often, and when. Plus, because your doing it dynamically, it catches cases that static analysis likely wont.
I've also had some success using Enterprise Architect's reverse engineering features, although this doesn't end up nearly as nicely (but you get a workable UML model which is nice!).
And finally, a tool called "Understand". This is pretty good at static OO analysis, but I think quite pricey and not that widely used.

Try Source Insight it is possible to configure the depth of the generated graph in this tool.
See also C/C++ call-graph utility for Windows platform

Check out SourceNavigator, it's open source, works on a bunch of platforms and has a Hierarchy Browser, a Class Browser, a Cross-Reference Browser and more that will allow you navigate and understand the code.
I'm using it for some time now especially when I have new code to go through and understand.

For a reasonably priced commercial product, you may want to check out SolidSX from Vizlogix (www.vizlogix.com). (If you are outside of North America, go to SolidSource -- www.solidsourceit.com.)
It generates a radial diagram that can be collapsed and expanded. It also integrates with Visual Studio (both BSC and .NET).

What's your definition of 'main vein'? You either want a graph reducer or skeletizer (you could find or write one and apply it to what Doxygen and the rest produce) or, 'main vein' has something to do with the function of the code and, I don't think an automated tool can help you with that. Unless you can point out to it 'These are the important bits that do input and output, show me only elements that are one or two steps away from the paths between these'. Hum, sounds like a cool tool to write :)
... the inheritance hierarchy, in some kind of collapsible view.
again, a sweet idea for a tool!

Related

Graph edit framework

I was looking at MeVisLab and I wondered if anyone knows a good framework for making a user interface similar to the one they use. I like the designing flow with boxes and arrows thing.
What I would really like is to able to integrate with C++ using Qt, and perhaps export the graph to xml of something like that.
There is another example of the interface here:
I hope someone knows something
Qt's Graphics View is a "framework" which does a good bit of the handling for the kind of scenario you describe. It doesn't take much code to get off the ground and within striking range of what you're looking for:
http://doc.qt.nokia.com/latest/graphicsview-diagramscene.html
http://doc.qt.nokia.com/latest/graphicsview-elasticnodes.html
I'm not aware of any open-source Qt-based programs that offer exactly what you want already written. Just noticed IBM did open source "DataExplorer", which is interesting to me...I might go take a look at that myself:
http://www.research.ibm.com/dx/

UML - How to manage big class diagrams?

For my project report, i need to show the class diagram of the software i've built which counts around 20 classes! The problem, is that when i render the class diagram in jpeg file(either using StarUML or ArgoUMl or whatever..) we can't see the details correctly (very big picture because of the large number of classes). Well, how to manage this situation correctly? Since the report is gonna be printed on A4 pages ?
Thanks !
With 20 classes I would expect at least 3 subsystems, (modules, layers), possibly more
Make package diagram showing the relation between those, one class diagram for each subsystem.
Add class diagrams for special things you want to show. Print each on A4.
If you can't split the diagram easily into modules, I'd consider that a design smell.
Its fun to print large diagrams on huge pieces of paper (like 500 tables on A0 ;-) but it really isn't of much use.
Producing a class diagram containing 20 classes is totally useless- what does it actually show? When using class diagrams I've never created a diagram that has more than about 5-8 classes on it.
The question to ask yourself is "what useful information am I trying to show with this diagram?". Don't produce a class diagram for the sake of it!
Breaking it down to demonstrate a particular design pattern, subsystem or component is what I find class diagrams useful for.
an other way is to not show all members but only the main ones, this reduce the size of the classes then the size of the diagram. Of course this suppose you use a tool allowing to choose which operations/attributs/relations must be visible, but this drawing setting is classical
may be you tool also have drawing setting to hide some part of the operation to reduce the width, for instance to show or not the parameters, or their direction, their type etc
Bouml (http://bouml.free.fr) has all this drawing options, and as it was said has PNG and SVG exports
best regards and happy modeling
Bruno
There are a few things you can do:
Bigger paper
Don't display method signatures
Don't display private methods
Partition your problem into more packages
Fewer classes per diagram
This is one of the problems with trying to treat UML like engineering drawings: Once you get it off a whiteboard, it's a poor language for communication. It doesn't read so well.
Generally a good way to deal with this is to create different diagrams for different modules or areas of functionality for your software. Alternately you could print the single image on multiple pages and show how to assemble them to form the full image.
I think it's the inherent problem that you're trying to show so many things in one diagram. Your question is just like "how can I put 100 words in a sentence without the reader getting tired of it?"
You can probably refactor it with FacadePattern. Basically it's just breaking down stuffs into modules. For e.g. Timesheet, PayCheck, BonusRecord can be ground into ManagementSystem. Product, Order can be grouped into OperationSystem, etc.
Use BOUML. The ArgoUML and StarUML are classics which everybody mention when it comes to question "is there any free UML software?". It's funny that being a historic software does not make the software unknown and unused. In case of Argo and Star the historic coefficient makes them known and used.
BOUML can export to SVG. This will solve your problems.I described the tool here
Thanks to SVG you will be able to quickly switch between birds eye view and detail view. I do this with Firefox. It's rapidly fast.
PS. I just noticed that you want to print the report. The SVG is then probably not what you want :\
Split your classes in several diagrams! When creating a UML model, you can have model elements such as classes displayed (no not) in several diagrams. A diagram is just a view of your UML model so that you can highlight modules in your specific diagrams.

Is there a way to automatically generate the data flow diagrams and flowcharts?

I am recently working on some long and obscure codes written by some other smart guys.
I'm thinking of generating the Data Flow Diagrams and the Flowcharts to facilitate my work. Is there any kinds of software that can do this job automatically?
P.S. Most of the codes are in C and Fortran.
Dataflow diagrams are harder because they require most of a compiler front end to derive the basic information needed to draw them. But you can get call and caller graphs as well as some kinds of entity relationship diagrams out of Doxygen with Graphviz.
Also, Graphviz is generally useful for drawing all kinds of graphs with readable layouts from raw data. It is easy to walk a tree structure and output a description in the DOT language for Graphviz to draw, for example.
Set Doxygen up with the right options, and turn it loose on the legacy code and you will get the beginnings of an internals document to help find your way around too.
"Code Visual to Flowchart" from FateSoftware may also obe of help.
You can try code2flow:
https://code2flow.com
It convert your code to Flowchart.
Dia is a program that resembles Microsoft Visio. It isn't as smooth, but it gets the job done. I always use this professionally when Visio isn't available. This is mainly for UML and Flowcharts, exports to png, and vectors, and I think PDF's as well.

flowchart best practices

Could some one point to articles / books on how to create good flow chart diagrams?
BoUML-it's free!
I've used this open source tool for the last 6 months at work to create UML diagrams:
bouml.free.fr/
I've used it on both a Macbook running OS X, as well as Ubuntu Linux on a desktop, both with success. It also does codegen (although I haven't used this feature myself). If you create a diagram from within BoUML, you can right click ->Tools->HTML etc,etc., and it and actually generate the diagram -- this will create a whole tree of html, css, etc., and include a .png file which you can later choose to import into a Word-like document.
If you're new to UML, and would like to explore that route, I suggest UML Distilled by Martin Fowler as a way to quickly ramp up. I still use this as a reference when I'm putting diagrams together and I forget some syntactical detail ;) The nice thing about UML is that most programmers will understand it. If you don't want to buy a book you can, of course, Google 'UML tutorial' and get a slew of free info.
Non-UML:
You can also use open office's draw application to do some simple flow charting. It has some nice non-uml shapes, so if you're not trying to be 'strict' in the sense of conforming to UML, and just want a simple flow chart, that may be a good choice.
Check this one out:
http://drakon-editor.sourceforge.net/DRAKON.pdf
Tutorial here.
Also get a copy of Microsoft Visio.

What is the ultimate program to make a drawing of a database model? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
One of the first things I do when I'm on a new project is design a database model. To visualize the model I use a 7 year old version of Smartdraw. Maybe it's time for something new. What is the ultimate program to make a drawing of a database model. Smartdraw is for Windows only. Is there something that can be used on unix as well?
The best tool is pencil and paper.
Perhaps not the answer you are looking for, but sometimes the most simple solution is the best. :-)
A whiteboard (and camera to take a picture afterwards)
Your brain is the best drawing tool.
I prefer to develop a database schema in a simple text file.
At first it contains just the table names, attributes and foreign keys:
company:
company_name
...
employee:
name
age
company_name -> company
...
...:
The syntax is not important.
It just needs to be clearly arranged and easy to change.
Later I add types and CHECK() constraints,
so the text file gradually transforms into valid SQL code.
Using a drawing tool in that early stage is just distracting,
because it encourages to waste your time with moving reactangles.
Instead, let your brain build a picture of the schema
in the same way it creates fantasy pictures while reading a book.
As the schema grows,
it becomes necessary to support the brain by creating an overview.
Here, however, pencil and paper are faster than any drawing software.
Also note that there is no need to clutter an overview with unimportant details.
Just sketch the table names and the most important relationships (foreign keys).
Any further details will decrease the value of this overview.
However, if you really feel more comfortable with extremely detailed graphics than with text files and overview graphics, you might want to try
DBDesigner4
or
WWW SQL Designer.
I'm happy using Sybase PowerDesigner for years now.
Did you take a look at Visio 2007 SQL Server Add-In?
You can find it here: http://dbalink.wordpress.com/2008/04/24/microsoft-office-visio-2007-professional-sql-server-add-in/
WWW SQL Designer is one of the best that I've seen, which is pretty amazing since it is all javascript. It can also import and export xml and sql code of everything you draw. And they've added nifty bezier curves since I last used it.
I don't know if it's the "ultimate" program for drawing database models, but I use Visio. Unfortunately, it only runs in Windows.
On the upside, I can create my own shapes, or modify existing ones, and save them in collections called stencils. I can also make my shapes "smart" by programming them to do various things when I double click on them.
I use a whiteboard and a camera as well. I second the pencil and paper. I keep a pen(cil) and pad of paper with me almost always because I am forever designing something in my head and need to jot it down. I like Visio as well but my favorite software program to use has always been ERWin. The price of that thing is just way out line, but it is great.
I like ERWin. Not Cheap, but it can reverse engineer or do initial design + generate CRUD and manipulate db structure. Viso is pretty good for this too, but its not as complete and of course as strong MS SQL leanings is capabilities.
I used to use Visio, but if your database server is MySQL, try MySQL Workbench. It has a linux version as well as a win32 version. Like their other GUI products it has its fair share of quirks, but it works quite well and has the ability to create a diagram of a schema and a schema from a diagram.
I also agree that a pencil and paper, or whiteboard and camera is a great way to sketch things out, but I do like the GUI tools for putting down an idea which is a bit more well formed or complicated.
I like to use the open-source mind-mapping program Freemind. It's similar to designing with pencil and paper in that there's not a lot of surface complexity to interrupt the design process.
But it has two huge advantages over paper/pencil:
node folding
easy drag-and-drop re-arranging
It is very easy to navigate the interface without using the mouse within about five minutes. You can add as many or as few details as you like and can always fold up the details to de-clutter your view. Here's a sample screenshot:
The circles at the ends of the Departments, Employees, and Hours tables indicate that there are more nodes that are folded up. You can go crazy with different fonts, background colors, and even HTML formatting. I just did a [Ctrl]-[B] to make my table names Bold.
FreeMind--and mind-mapping software in general--provides its biggest benefit by staying out of the way of the creative process. It's the first tool I turn to when starting a new project from scratch.
NOTE: I've only ever used the program on Windows, but it is available on Linux.
DIA is not bad, and there are tools to actually generate some code from some types of models. If you are using PostgreSQL, there is even a tool for going the other way, pg-autodoc.
DIA is available for Unix, and I believe Windows as well.
I used to use Viso but now, as I'm more Mac based I use Omnigraffle.
I do have to admit though, as andyUK does, I do a rough sketch on paper.
It also depends on what Database you're using. If it's MySQL then there are quite a few visual development tools available, just have a google
There may be more technical programs, but I use SmartDraw. I would also like to note that 'ultimate' is up to your circumstances. Find what works best for you or you and your company. What works for you is the 'ultimate'.
Brainstorm/sketch the database on paper/whiteboard first, and then go with a diagram tool.
Which tool depends on your target database. We use SQL Server and thus the designer in SQL Server Management Studio works great for us, since we create the database itself at the same time.
For linux I use umbrello
If you're looking for a cheap solution/tool without any reverse/forward engineering capabilities, MS Visio might be your best bet. However, if you're planning to invest some money toward ERD tool, spend it on ER/Studio.
I used to use and be champion of ERWIN. As soon as I started to use ER/Studio, I became fan of it. I'm an enterprise data architect at one of the Fortune 100 company and I don't know how to get my work done without it.
PS: I don't have no affiliations with any of those products and companies.
OpenOffice has a vector drawing tool, and Inkscape is a another good one.
Otherwise, you can use Graphviz (dot language) to generate such diagram out of a textual description.
There are also some tools to generate such diagram out of an existing database (I first thought it was what you were asking).
If you don't need much take Dia.
I used Power Designer. It's powerful but rather complex.