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

I do not own UML, but 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 good enough for C ++ "reverse engineering" code (i.e., creating UML class diagrams based on existing C ++ code).

I downloaded a trial version for both of these applications. However, I cannot figure out what to do to create a class diagram in any of these applications.

In Rational Software Architect, I created a UML project, but I cannot find any opportunity in the program to select and reengine my existing C ++ code.

In Enterprise Architect, I was able to import my C ++ code, but all the elements (classes) appeared in a useless, intersecting diagonal line inside the diagram. I tried to make other settings, such as a circle, but it was also impossible to read them because the diagrams were so large (due to attributes and methods taking up a lot of space) that no amount of panning and scaling was useful. I would like to hide everything except the class names (i.e. Do not display any methods or attributes) so that all 20 classes are displayed conveniently and legibly on one screen.

However, I cannot find a way to hide everything except class names. Rather, when I found an option (in Enterprise Architect) that seemed to be able to hide everything except the class names, for some reason all the elements disappeared from the class diagram and didn’t repeat the steps, as well as removed and re-added packages the diagram appeared again classes.

Note. My C ++ code (at least the files that I chose to import into Enterprise Architect) is only about 20 classes.

Unfortunately, a very thorough search of the documentation for both of these programs gives only general information - there were no specific instructions for reverse engineering for any of these programs, as far as I could find.

I would be grateful if someone would tell me the basic steps to create a clear and easy-to-navigate chart. (i.e. C ++ - to-UML), which only shows class names, so about 20 classes fit (legibly) on one screen using either Enterprise Architect or Rational Software Architect - OR any other tool that is capable (I offer EA and Rational just because they were highlighted in other StackOverflow answers as the best programs available for this purpose).

+8
c ++ uml enterprise-architect rational
source share
1 answer

This answer applies to EA.

You can import individual files or entire directories, recursively or not. Importing a catalog is by far the most common case; importing a single file does not automatically create a chart.

When importing the 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 consists of only 20 classes, most likely they are in the same directory and / or namespace, so play around with this option (Package Structure in the Import Source dialog box) to get the right number of diagrams.

In the same dialog box there is a button “New diagram parameters”, which opens another configuration dialog box, in which you can choose whether the diagrams should contain class attributes and / or operations. You can also make a decision based on visibility, for example, only for public participants.

This dialog only affects what is shown in the diagrams when they are created. Participants are still imported, just not displayed. This is similar to what you need.

You can change the display settings for any chart by double-clicking on its empty area or by right-clicking and selecting "Properties". It looks like you entered this dialogue and changed something, but I can’t say that. The situation you are describing is where you cannot display the screen the way it was, not the one I have ever encountered in EA.

You can also select display options for each class by right-clicking on a chart and selecting Feature Visibility. I do not recommend you use this in reverse design circuits, I just mentioned this for completeness.

The layout you are describing, with all the classes in a meaningless diagonal, tells me that the chart does not line up properly after being created. Creating a chart is a two-step process; first, all classes are discarded on it, then the layout is applied.

This is strange, since EA automatically creates the generated charts, and I could not find an option that allows you to deselect this behavior. If this fails, send a bug report to Sparx Systems. You can always lay out a chart by opening it and choosing Layout Scheme in the Top Level Chart menu.

If, finally, your classes are distributed between different packages of namespaces and for EA to generate several diagrams for them, you will have to combine them manually. Do this by opening both diagrams, selecting all (Ctrl-A) in one, copying (Ctrl-C) and pasting (Ctrl-V) in the other, then again ask EA about the layout scheme.

So:

  • Right-click the empty package in the project browser, select "Code Engineering" - "Import Source Directory".
  • In the dialog box, select the root directory and source type.
  • Check "Create logic for each package" and select the package structure that best suits your original structure.
  • Click New Chart Settings, and in the new dialog box, turn off Show Attributes, Show Operations, and Show Property Methods, if applicable.
  • OK both dialogs.
  • If multiple diagrams are created, copy all the classes into one diagram.
  • If the layout does not look good, select Chart - Layout.

Hope this helps.

+12
source share

All Articles