How i add array attrribute in class diagram UML - uml

am using uml to implement my class diagram.
I have a class diagram named user . I want to add user preferences as an array of string without using table.
I would ask if i can use an array of string as an attribute.

No problem. Simply append the array dimension as shown below:
Defaults can be specified following the equal sign.

Related

How can I add a simple generic type annotation for a dictionary in UML?

In a UML class diagram, the value of one of the attributes of a class is a (typed) dictionary. What is a proper UML type annotation? (Within the box; not as an association.)
For example, in Python I would annotate this attribute with Dict[A,B] or possibly Mapping[A,B]. I am not asking about Python; this is just one example of a somewhat generic attribute annotation. I am open to the possibility that UML does not offer a language agnostic equivalent to this, but I am hoping that is not true.
Comment: I am asking about generic attribute annotation, directly with the class box. I do not wish to add a separate class box for Dict to the diagram. Therefore this is not a duplicate of How can I represent a Python dictionary in UML?
In UML Dict is typically model as a template class with two template parameters for instance named key and value.
Let's say you want the class C has the attribute a being a Dict[A,B], so you have a binding having the template param substitutions key -> A and value -> B.
There are several ways to show that in a class diagram.
For instance using the class DictAB to model Dict[A,B] :
or if you prefer :
But it is also possible to not use the auxiliary class DictAB and to use the textual representation of the binding expression (see formal/2017-12-05 ยง 7.3.4 page 26) :

How to specify the return type of a method that returns a list of values in StarUML?

I have two classes (say Database and Record). In Database class, I have a method named getRecords() that returns a list of Record objects.
In Java, the above method can be written as:
List<Record> getRecords(){..}
In StarUML, while designing Class diagram, I tried giving
+getRecords() : Record[0..*]
But StarUML refused to create method like above. When I tried with the one below, it works
+getRecords() : ArrayList<Record>
But this is more specific to Java. I want to implement something like Record[0..*] in StarUML. Is it possible to write methods in such format or the Java style of return type is the only solution ?
I don't know why StarUML refuses to parse the text, but you can still create it via model.
Add the operation and call it getRecords()
Right-click on the operation (in diagram or model), and select Add > Parameter
Select parameter in Model Explorer (probably the parameter is already selected when you created it) and set the direction parameter to return. This is how UML represents return types.
(Configure the type, multiplicity, and anything else you need.)
Note that the default collection in UML is Set, so you should check isOrdered, as List is an ordered collection.

Hashmap in UML diagram?

I want to write a class diagram for a class that contains a hashmap.
Normally, I would do this:
But my Map looks like this:
private Map<Beacon, String> beaconRoute;
The key is a custom class.
How can I describe it in an UML diagram?
Use beacon : Beacon inside the qualifier rectangle and use the String data type as the target type (instead of Employee). The property beaconRoute is the association end name. You don't have to be so literal as to have a Map class in UML--doing that loses sight of the problem domain. Not that I understand why a Beacon would map to a String, though. Did you reverse the key and value by mistake?
You can use an association class for that:

How to make method arguments visible in StarUML diagrams

I am trying to display the arguments in a sequence diagram using staruml
Is it possible to display the arguments like this?
1: saveResult(int value)
Go to Toolbox -> Sequence -> Stimulus.
Drag from one object to another to create the stimulus line
On the side you should see the Properties for the call
In Name put the method name, i.e. saveResult
In the Detail section you can specify arguments. Put the arguments there, i.e. int value
If the arguments don't appear then change the properties of the Sequence Diagram. Change MessageSignature to NAMEANDTYPE
Try the sequence diagram user manual.

How to draw a relationship between a property and a class in ArgoUML?

In ArgoUML, I have the ability to put a class Type to any property of a class. For example, I can declare a customer property with a Customer type in the Order class.
I can also easily draw a relationship from class to class:
But I can't figure out how to "draw" the link from the customer property to the Customer class. The link is never really connected to the property, but rather to the entire Order class.
I can move the position of the link manually:
But it's never really "locked" to the customer property, and can be moved automatically by the software at any moment.
Is there a way to do this?
You can not have an association in UML which is not connecting the entire two classes. It is not possible to touch the property inside the class.
Workarounds are:
add a note linked to the property
add an icon to the property which would be designed like an association.
I don't know if this advanced icons customization is available in this free tool but it is in other tools.
I found a flash demo which shows the association attribute with an icon. Look at : http://www.download-omondo.com/show_association_member.swf
If you need to understand what mean an association in UML and code generation in Java then have a look at this demo: http://www.download-omondo.com/association.swf
Hope this help.
ArgoUML follows the UML specification. Associations are drawn from one class to another. Attributes are drawn inside the 2nd compartment of a class.
The association type closest in meaning to an attribute is composition, but they are not equivalent.
You should never portray something AND as an attribute of a class, AND as a separate class associated to it.
E.g. 1. an Order may have a Number, that may be used by the customer to identify his Order. The Number is best portrayed as an attribute (in the 2nd compartment of the class).
E.g. 2. an Order may be associated to the Customer who placed the order. The Customer is best portrayed as a separate class, since it has its own lifespan (behavior), associated with the Order. This allows to show multiplicities and roles at both ends of the association line.

Resources