StarUML in generating C++ code - uml

I'm new to UML and I have written a Sequence diagram for a Voucher User Interface, it is a small pet project I'm doing to learn UML. I have written a decent Sequence Diagram in StarUML and now I would like to generate the C++ code, the step is very simple I just go to Tools/C++/Generate Code... But there I face a problem, which you can understand from the screen captures below. I tried various places but I could not find any help, anyone experienced in StarUML who could help me go further?

Haven't used starUML for a while so things may have changed. But:
Last time I looked, it didn't provide templates for behavioural code generation. The only codegen templates were for static structure (classes, attributes, packages). If that's still the case then I suspect the empty panel arises from it not finding any suitable model elements to generate code for. i.e. your Sequence Diagram package doesn't have any classes in it.
You might be able to work it out by looking at the codegen templates; they should be in
<STARUML_INSTALL_PATH>\modules\staruml-generator\templates
hth.

I just tried to generate the code from start uml.
With Version 5.0.3.1570. It works well.
I got the diagram instantly.
One issue, it actually did not generate the composition / aggregation stuff but, then, I did that manually.
Since its propitiatory for my organization, I cannot revel but, sequence is exactly the same as of yours.
I choose Design model & then gave file path in dialog box.

Related

How can I generate a UML diagram without a GUI

I'm trying to create a UML diagram from the command line without preexisting code.
Eventually I'll write code in C++/Java, but I need to create a diagram first.
I'm thinking of a header-like file, which could be read and could generate a diagram.
Of course, I could just create a header and generate it. However, I'm not supposed to write any code until I've submitted my diagram (I'd also just like to have an efficient way to do this for the future).
UML does not require application to draw. On the contrary one of the main usages of UML is to model the application that you're going to build to understand it better and make a better code as a result.
You also don't use application you create to draw UML diagram. You can use any application that supports UML modelling. Simple Google search or visit on Wikipedia will give you tons of options. You may even take a sheet of paper and a pencil. I've seen a course of UML, where participants did not use computers. They were supposed to learn UML, not tools that allow to draw it.
Finally (answering the question stated in the question topic), UML is in no way limited to model only graphical applications. Static structure and dynamic behaviour of the system exists regardless if user communicates with it through a GUI or command line.
Are you sure you understood the reason why you are supposed to make a UML diagram or do you disagree with that reason? What I can definitely suggest is to find a good book about IT business analysis using UML. This site is not to recommend specific books, but again Google will be your friend here.
As according to the comment the goal is to actually generate a UML class diagram from text let me add a second part of answer
First disclaimer. In general SO is not a place to ask for tools and that question is brushing it. Let me make my answer more generic though.
UML is in general graphical language so technically what you need is something that will parse text version of your "diagram" into a nice picture.
Most if not all tools keep UML in some textual format, be it XMI or some internal legacy solution. The problem with that is that the format is usually pretty complex.
There are some tools that are intended to "draw" diagram by typing text and that's probably something that would suit you best. In general I definitely prefer "normal" GUI but if you insist yuml.me has a nice and easy to understand textual layer based on which it generates really cool diagrams. You may expect you will find others as well, so as usually, ask uncle Google. As suggested by Thomas Kilian in a comment, PlantUML is another example as it can work without GUI and "is an open-source tool allowing users to create UML diagrams from a plain text language." (quote after Wikipedia)

Diagrams to describe behavior of application

I built an application which is integrated in open source program( you just download the binary of the program, run it and then my integrated module will execute when you click on one single button called translate. That's all. )
What the application does is that when user builds some schema in the open-source project I mentioned above it generates C++ code for the schema. It's java program written in OOP style( classes, polymorphism, inheritance, encapsulation). There also runs some algorithms like top sort for finding topological sorting or bfs.
Since I study software engineering and will be presenting the application I would like to draw some UML diagrams or diagrams in general which would help me to better describe the application/ behavior of application itself.
Since it's not typical web-based project ( does not use any database etc... ) except for class diagram I don't know what what would be good to use.
Could anyone give me some diagram names which would help me to describe the behavior of my application better? I appreciate all the help.
You are looking for sequence diagrams, activity diagrams and/or state diagrams to describe behavior.

Not exactly following what is depicted on project UML diagrams

This has been confusing me for quite some time. I have an app which is already done, but since the client is looking for a detailed documentation of it, I now have to create diagrams. The point where I get so confused is, whenever I make the diagrams, it just seems that the diagrams are not as exactly the same as what my coding looks like.
For example, on my class diagram, I have a class called 'announcements' and under that class is a method which getAnnouncements(). But in actual coding, you'll never find a method that is named getAnnoucements() since I opted to not create a method for it and instead put the codes directly on the main class. I know it's not a good coding practice, but what if? So these are my questions: Do I really have to follow what is on the class diagram? Or since I'm using reverse engineering, do I have to follow what is on my code and make diagrams of it?
If you're making a documentation and you're making a UML at the code level follow whatever you actually have in the code.
The benefit of this approach will be that
you really have diagrams similar to your code
you (and your client) will be able to recognize parts of poor code (i.e. not following various standards) - like those you describe. It gives chance to improve it in the future
The drawback is that you might need to correct the automatically generated diagram. Each time you generate it.

UML and documenting long methods

I am using UML to document parts of an older c++ program. It's only a portion of the code, but documenting it has made me insane since even this process is quite large. So far I have used class diagrams for the relevant code and some activity and sequence where necessary.
My question is I feel what I have done so far is good for the overall documentation but I want to get down to the dirty details of a few methods and one of them is 202 lines long, what should I use for this? An activity diagram or sequence?
I am using Visio for the UML documentation.
Thanks.
A rule of thumb might be that if it seems like there are multiple agents handing off flow between each other, use sequence; otherwise, activity. In a single function, activity is probably best - but not necessarily.
Try to imagine what it's going to end up looking like, put yourself in your ignorant reader's shoes, and think about which will tell the story better.
Is splitting up the function an option?
The question is: Do you want to describe the process or the interactions between objects that those few methods are executing? The process can be broken down into activities which are performed, their composition and data flow. Interactions are comprised of messages sent between objects.
Well,
Short answer is:
If you want to document an algorithm (that is used by one of your system object^s method): Use Activity diagrams.
Long Answer:
For my experience UML documentations are the worst ones.
People generally use Uml Tools which automaticly reverse engineer code to Uml (generally class diagrams, and sometimes sequence diagrams) and diagrams that are automatically generated are generally has many details and sometimes nonsense.
As an advice "Comments your code properly" and use tools like Doxygen. They are better for Code Documentation.
But you can use UML for Software Architect Document.[SAD]. Craig Larman has nice section and example of it at his books about Documenting Architecture
Motivation: Why Create a SAD?
When someone joins the development team, it's useful if the project coach can say, "Welcome to the NextGen project! Please go to the project website and read the ten page SAD in order to get an introduction to the big ideas." And later, during a subsequent release, when new people work on the system, a SAD can be a learning aid to speed their comprehension.
Therefore, it should be written with
this audience and goal in mind: What
do I need to say (and draw in the UML)
that will quickly help someone
understand the major ideas in this
system? [ Applying UML and Patterns Third Edition By Craig Larman ] [Chapter 39. Documenting Architecture: UML & the N+1 View Model]

Generate class diagram from existing javadocs

I'm using an external java library for which I only have the javadocs and do not have the source code. I'd like to generate a UML diagram from the existing javadocs so that I can visualize the class hierarchy using something like Graphviz. Is that possible? Note that what I'm looking for is a graphical version of overview-tree.html.
Please let me know if you have any ideas and/or suggestions.
Thanks,
Shirley
I don't believe that there is such a tool. Most of the reverse engineer tools depend on the actual code. The javadoc information isn't guaranteed to match the code as a 1:1 for the structure, thus making it unreliable.
I'm not familiar with any off-the-shelf solution for this purpose. Most commonly folks have the source code that generated the JavaDoc.
That being said, the overview-tree.html traditionally has a fairly straightforward HTML format.
It should not be difficult to write a script that would read the file as text or as a DOM, reconstruct the hierarchy of UL and LI tags, and use that to build an input file for graphviz. I've done similar stuff in the past with other forms of data.
It's just a matter of time and proficiency with the scripting language or appropriate tools.
The one problem of this approach is that you would only get the hierarchy of classes. You would have to make it somewhat smarter if you wanted to get the "implements XYZ" and create multiple hierarchies. Even if you could get that data, you would have to manipulate GraphViz's levels to get it to provide an appropriate layout once you have this multiple inheritance structure.
Of course, adding the details of the members would turn this into a whole new problem since you will have to access other HTML files.

Resources