How I can show an attribute as a two dimensional array(matrix) in UML? - uml

I am doing the UML of my system and I have an attribute boardGame that is a matrix (array[6][6]).
What is the correct way to show it in the UML? I tried this:
Game
-boardGame: array[][]
but the program I am using to do it (SatarUML) does not accept it in that way.

Simply you can show it like this (assuming it's untyped like in your example):
(note that the square bracket pairs [] are rendered with a sub-optimal font from the UML tool)
If it's typed use this format:
where you need to replace type by the one you are actually using.

Related

Define the multiplicity of an association by an attribute

In the example I made every object of the type "Folder" have an array of type "File" with the name "content" a size of "n" as a private attribute (just saying my understanding of it to make sure that I am not already wrong there). That's how I see it in most examples but I never understand what "n" now is. Is it another attribute of the "Folder" object or is it something that we specify in another part of an UML diagram or something else completely?
What I am trying to achieve is that every object of the type "Folder" has an additional attribute that specifies the size of the "content" array.
Of course, you can not only write 0..*, but use any concrete number, too. If that number has some external definition, you can use there n, as you have it.
The external definition means "not defined by class diagram elements, except notes". Everything that you need to be said on a class diagram page, but can't because of the UML limitations, should be put in a note.
So, n can be defined in appropriate note on the page or in some different document or both.
As #Kilian had mentioned, in the case of some more complicated dependencies of such variables you can use constraints. This way seems to me the most powerful.
But if n has no objective definition or dependency, but is a simple variable that can have any meaning, then it will be correct to use a rule, such as 0..*, or 1..*, or maybe 3..5, according to the reality you are working with.

XML Schema for choice between element and #PCDATA

I have a preexisting XML document type that has an element that can have two content types: some elements, or just text. Modeling this as mixed content is overkill, and JAXB's XJC creates a very ugly binding as a result.
<bars><bar .../><bar .../></bars>
versus
<bars>Just a bunch of #PCDATA</bars>
xs:choice seems structured only for complex types (not simple types like xs:string). Is there a way to express this choice, between elements or text, using XML schema? In DTD this would be something like
<!ELEMENT bars (#PCDATA | bar*)>
The language you want to define (either a sequence of character or a sequence of bar elements, but not a mixture) cannot be defined in XSD 1.0 (or in XML DTDs, either; your DTD notation would make sense but is not legal in XML DTDs).
In XSD 1.1, you can use an assertion to ensure that if any bar elements are present as children, no text nodes occur (or only text nodes that contain only whitespace).
A simple way to achieve roughly the same effect is to say that the bars element contains either a sequence of bar elements or a single stringvalue element (call it whatever you like), where the stringvalue element contains -- as its name suggests -- just a string of characters.

Adding a stereotype to an attribute in Dia

Is there a proper way of adding a stereotype to an attribute (not operation) in Dia? So far I'm inserting stereotypes to attribute names, but it has a slightly different order.
What I have:
+<<val>> count: Int
How (I think) it should look like:
<<val>> +count: Int
It looks like you are typing the stereotype and angle brackets. Instead, look for a way to apply a stereotype in the GUI.

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 specifiy enumeration literal as default value in UML Attribute?

I currently doing some model transformations using EMF-UML-Implementation.
In my model transformation I create an uml class with some attributes. The attributes are type of enumerations I also created.
Some of the attribute should get a default value. The default value should be enumeration literals.
The question now is, how do I get the enumeration literals to the defaultValue-property of the Property.
I already have found that I have to use ValueSpecification. But the UML superstructure says not much about that (page 139 f.). Which properties do I have to use for setting the defaultValue to enumeration literals?
I think the main problem I have is, that the use of ValueSpecification is unclear to me. Currently I only use default to set the default values, which is type of String.
The defaultValue-property takes a ValueSpecification argument. So in your case, you need an InstanceValue for this purpose (which derives from ValueSpecification). The InstanceValue itself has an instance-property, which takes an InstanceSpecification as argument. As EnumerationLiteral derives from InstanceSpecification, you can now simply assign one of your EnumerationLiterals to it.

Resources