How should I represent the main method (java) using UML? - uml

I have three classes: Bridge, Main and Car.
I have no idea about how to include the main method in my UML representation.
Should I list all the attributes...as well as the main method?
The main method does:
- a bit of calculation
- instantiate the other two classes
I would draw the Main, this way:
---------------------------
Main
---------------------------
---------------------------
+ main(String[] args): void
---------------------------
Is that correct?
Thanks

Your drawing is good, you just need to underline the main method to show that it is static. I think that you should model it since it shows that this class is one entry point to the system (there may be more).

you don't need to include main method in your UML and also as I remember, you should put all the members and methods that are present in your class except the main method. Since the main method is somewhat a given already

The main method should be drawn like this:
+ main(args: String[]): void
____________________________

Main class has, by definition, no instance; Relationship like association, agregation and so on are used between objets, so the main class in a diagram is not very usefull.

Related

UML class diagram - how to show that one class includes another

I have a situation similar to this:
classA.h:
class A{};
classB.h:
#include "classA.h"
class B{};
Is there a way (and should I do it?) to show that classB uses (includes) classA even though there is no heredity involved? ClassB doesn't even have classA as a member, but I feel like it would make sense to somehow show this in the class diagram.
You can do it two ways. The first is to simply enlarge B so it can hold A like this:
Note the fully qualified name for A.
Another way is to use an import relation:

UML - How to show a class instantiated by its static main method

It is a Sequence Diagram HowTo question, not a HowTo code.
I am using Visio 2010 and developing >> reverse engineering from Microsoft Dynamics AX 2012 / X++. Yes people its all about how to map static on UML.
My class is instantiated from FORM using at its void static main(). This calls another static method, say construct() which returns an instance of the same class.
I want to show the class (in static methods) and the resulting object separately some like the meta class runs (self msgs) and finally produces the class object which finally takes over. But how will a self msg call return a value ? How do I connect it with the resulting object of the class ? I hope I make enough sense to make you guys understand.
Note, the class is not a static class, but it has a static constructor.
If you want to depict a call to constructor (i.e. static operation that is responsible for creating an object and (usually) returning it as a reply) then you have to use a createMessage construct i.e. a dashed line with an open arrow and the word create on it. While this is not directly stated in specification, usually in such case the arrow points on the lifeline box (rectangle) rather than a line itself (however I've seen information that both notations are correct).
Note that in this case the logic of constructor is hidden (encapsulated) which is a good idea in general.
You can find more details in UML specification in section 17.4, especially 17.4.4.1 and an example in section 17.6.5 on Figure 17.14.
If you want to use a static operation other than constructor and call it without a use of class instance you have to model class as object (after all class is an object itself at least on analytical level). Note that the type of message can be either synchronous or asynchronous depending on your needs.
With this approach you can provide details on how the class handles this function (i.e. what other calls does it make).
For more details see "Applied UML and Patterns" by Craig Larman, section 15.4, Figure 15.20. Note however that Larman suggest a use of <<metaclass>> stereotype. Yet the called object is a class (metaclass is a class whose instance is class so this is not our case) so the stereotype should be <<class>>.

UML Class Diagram - Generalization

This image illustrate the UML I must follow in this project.
The problem is, I don't know what means the private parameter "ator" in the arrow. It should be declared in the class Ator or Personagem? I do know that Personagem is a subclass of Ator.
Because the arrow is unidirectional, you can be sure that -ator should be placed just next to the Ator class. This implies that a private attribute ator exists for class Personagem.
Then, from any method in the Personagem class, you can use some code like this.ator.getId()

Do I Need To Make A Class Diagram For All Object Instances and Microsoft Methods That I Use?

I have the following classes made in C# in a program called MyGrades:
Menu.cs
Grade.cs
Student.cs
I have the following instances in my Student class:
private Grade test = new Grade(300);
private Grade hwQz = new Grade(700);
In Menu.cs I use the following Microsoft methods and Microsoft Class respectively:
Console.Clear()
Console.WriteLine()
Console.Write()
Console.ReadKey()
ConsoleKeyInfo key = Console.ReadKey();
In Grade.cs I use the following Microsoft methods:
Console.Clear()
Console.WriteLine()
Console.Write()
Console.ReadKey
Do I need to make class diagrams for Console as well as for all my class instances?
The programming language doesn't require you to draw a class diagram.
If your course instructor requires you to draw diagrams, you'll need to ask them exactly what they want.
Generally you should include other classes when they are relevant to understanding the diagram. It is not useful to have everything point to, say, the Logging class. If something especially interacts with the Console that might be relevant.

ArgoUML Operations

I have created an ERD (Entity-Relationship Diagram) using ArgoUML and I wish to create two operations within a class which both have a void return type. However, I am only able to create one operation which returns a void type.
For example:
I am able to set the return type of bookInitial() to void but whenever I try to set the return type of bookFollowUp() to void, the option is not available.
Having checked with other classes in the project, it would appear that each class only allows one object to have a void return type - is this true for all classes?
Is there is there a way to assign the void return type to more than one operation?
Thank you.
ArgoUML is a UML modeling tool, so it doesn't have E-R diagrams. You were probably working with UML Class Diagrams.
What version of ArgoUML are you using? If that really doesn't work, and you're running the latest version (0.32.2), it sounds like a bug which should be reported at http://argouml.tigris.org/project_bugs.html
I have no problem in creating two operations that return void (with Argo v.0.24). In fact, when adding new operations they are created as returning void by default

Resources