Reverse engineered project to graphical UML diagram - c++

I've started to work on a quite big C++ project. I've used BOUML to import the code base with the intention to create a visual UML diagram.
Now I've reversed the project and I see the classes, namespaces, methods and such in the project browser but I can't figure out how to create a graphical UMl from it, may anyone here help me?
Manually draggign the elements from the browser into the main area doesn't seem to be allowed as the cursor gets a forbidden icon and dropping the elments doesn't do anything then... how do I even create the UML myself?

muszeo2 is right, the reverse create the packages / views / artifacts and classes and their members, after you have to create the diagrams by yourself. Sorry but BoUML is not extra lucid and it cannot by itself create the right diagrams of the right kind containing the right elements with the right drawing options ;-) So create your diagrams and drag&drop the elements you want to show etc, they are several features helping you to make diagrams with elements already created or not.

I also made some video tutorials available on https://www.bouml.fr/documentation.html, I encourage you to look at them, starting by starting.wmv then cpp_example.wmv for instance, but you can also look at the others because the rules are quite identicals. These video tutorials are old and many features was added since I made them, but this is a good start.
You cannot drag&drop from browser to no where (I mean not into an opened diagram) nor when the element cannot be added in a diagram

Related

creating UML or class diagram manually from existing project

Is there anyway to build manually a class or UML diagram from some part of existing code in Visual Studio Professional? Assume there are plenty of project and classes. Can i manually select some of the classes (with only some of its base/derived classes and member functions) I am interested in, and they are automatically transferred to boxes with arrows and so on...?
The trivial and slow solution is to draw some boxes and corresponding arrows and then write the name of classes or member functions into boxes (With some drawing programs like Dia). However, can it be done maybe using a more efficient way with any plugin or extension?
Because, my final aim is to make my own documentation (visually) from the code i am working at. The code is big and I want to develope my own documentation only on some selective parts during the next years...
You can install the Class Designer component.
In addition, UML Designers have been removed.

How to create class diagram from source code using either Enterprise Architect or Rational Software Architect?

I am not fluent in UML, but I would like to create a class diagram based on existing C++ code. Other StackOverflow questions have indicated that two programs - Enterprise Architect and Rational Software Architect - are fairly good at "reverse engineering" C++ code (i.e., creating UML class diagrams based on existing C++ code).
I have downloaded the trial version for both of these applications. However, I cannot make any headway into understanding what to do to create a class diagram in either of these applications.
In Rational Software Architect, I have created a UML project, but I cannot find any way within the program to select, and reverse engineer, my existing C++ code.
In Enterprise Architect, I was able to import my C++ code, but all the elements (classes) appeared in a useless, overlapping diagonal line within the diagram. I attempted other settings, such as circle, but these were equally impossible to read because the diagrams were so large (due to the attributes and methods taking up alot of space) that no amount of panning and zooming was useful. What I would like is to hide everything except the class names (i.e., not display any methods or attributes) so that all 20 classes appear conveniently and legibly in one screen.
However, I am unable to find a way to hide everything except the class names. Rather, when I found an option (in Enterprise Architect) that seemed like it might hide everything but the class names, for some reason the elements all vanished in the class diagram, and no amount of repeating the steps & deleting and re-adding packages made the class diagram reappear.
Note: My C++ code (at least those files I selected for import into Enterprise Architect) amount to only about 20 classes.
Sadly, a very careful search of the documentation for both of these programs provides only generalities - no specific instructions are given regarding reverse engineering for either of these programs, so far as I could find.
I would be grateful if someone could tell me the basic steps to create a legible, easy-to-navigate diagram via. reverse engineering (i.e., C++-to-UML) that shows only the class names, so that about 20 classes fit (legibly) on one screen, using either Enterprise Architect, or Rational Software Architect - OR any other tool whatsoever that is capable of doing this (I suggest EA and Rational only because they have been highlighted in other StackOverflow answers as the best programs available for this purpose).
This answer applies to EA.
You can import individual files or whole directories, recursively or no. Directory import is by far the most common case; single file import does not allow you to create a diagram automatically.
When you import a source directory, you have the option of creating diagrams for each UML package, or no diagrams at all. You also decide whether to create packages for each source code directory, namespace (default) or file.
If your code constists of only 20 classes then it's likely they're in a single directory and/or namespace, so play around with that option (Package Structure in the Import Source dialog) to get the right number of diagrams.
In the same dialog, there's a button "New Diagram Options," which opens another config dialog where you can choose whether the diagrams should contain the classes' attributes and/or operations. You can also make the decision on a visibility basis, eg show public members only.
This dialog only affects what's shown in the diagrams when they are created. The members are still imported, just not displayed. This sounds like what you're after.
You can change the display options for any diagram by double-clicking an empty area of it, or right-clicking and selecting Properties. It sounds like you got into this dialog and changed something around, but I can't really tell what. The situation you describe, where you can't get the display back the way it was, is not one I've ever encountered in EA.
It is also possible to select display options on a per-class basis by right-clicking it in the diagram and selecting Feature Visibility. I don't recommend you use this in reverse-engineered diagrams, I'm just mentioning it for completeness.
The layout you describe, with all classes in a meaningless diagonal, suggests to me that the diagram isn't being laid out properly after creation. The diagram creation is a two-step process; first all the classes are dropped onto it, then the layout is applied.
This is strange, as EA automatically lays out generated diagrams and I haven't been able to find an option which allows you to deselect this behaviour. If this persists, send a bug report to Sparx Systems. You can always lay out the diagram by opening it and selecting Layout Diagram from the top-level Diagram menu.
If, finally, your classes are spread out among different packages and namespaces so that EA generates multiple diagrams for them, you'll have to merge them manually. Do this by opening both diagrams, selecting all (Ctrl-A) in one, copying (Ctrl-C) and pasting (Ctrl-V) into the other, then ask EA to Layout Diagram again.
So:
Right-click an empty package in the project browser, select Code Engineering - Import Source Directory.
In the dialog, select the root directory and source type.
Tick "Create Logical Diagram for Each Package" and select the Package Structure which best fits your source structure.
Click "New Diagram Options" and in the new dialog untick "Show Attributes," "Show Operations" and "Show Property Methods" if applicable.
OK both dialogs.
If multiple diagrams have been created, copy all classes into a single diagram.
If the layout looks bad, select Diagram - Layout Diagram.
Hope this helps.

C++ code visualization

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!

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.

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.