Proper way to put array in UML diagram? [duplicate] - uml

This question already has an answer here:
How to represent an attribute's data type as an array of objects on class diagram?
(1 answer)
Closed 2 years ago.
I am new to UML diagrams, so this may be a very ignorant question though I can't find the answer anywhere.
There is a class Classroom that holds an object of lecture times. Should lecture times be its own class or should it be an attribute of Classroom?
Feel free to critique notation.
Edit: I have already seen this post and it has not helped. I would like to know if LectureTime should be a separate class.
Option 1:
Option 2:

You create a new class if it has more than a single attribute and/or additional operations (which are not just a getter/setter). Or of you plan to add them in a later phase.
In your case lectureTime is obviously a simple type and the 2nd variant is to be preferred, except see above.
However, instead of the round braces you should use square brackets like validLectureTimes[] or validLectureTimes[0..*] which are equivalent.

If LectureTime is an Entity then yes. I guess it is, because of the relation you've added.

Related

How to model method parameters in class diagrams [duplicate]

This question already has answers here:
UML: when one class have as method parameter pointer to other class
(4 answers)
Closed 11 months ago.
I have a project where class Foo has a member function which takes class FooParam as a parameter. Now I want to draw a UML class diagram representing the relationship between class Foo and FooParam.
From the options on the table, inheritance, implementation, aggregation and composition are automatically excluded. Thus, the options that are left are association and dependency, but to my eyes none of them fits quite right.
Given the options, how exactly do we model method parameters in class diagrams?
I agree with Gerd, you will not see a "link" or "relationship" between Foo and FooParam classes. I put below what you should see by default.
Of course, you can always add an explicit link (as a dependency for example) but it is, for me, duplication of the information...
The best is maybe to have a tool which would be able to compute this "link" or "relationship" and show it to you in some way.

Default init Object of an attribute in UML

I have this attribute in Java:
private final Object MUTEX = new Object();
How can I show the init of a new Object in the UML Class Diagram?
EDIT:
The attribute MUTEX is used only for synchronized (MUTEX) operation.
So I was wondering if the initialization of this variables is needed to be specified in a UML class diagram, but i'm not sure if this initialization is behavior like or structural specific.
A class diagram is meant to show structure. As a part of structure you can show initial values of properties as answered in this question.
To show the operation "in progress" you need to create a Sequence Diagram where you can show behavior. The question would be: why? A simple initialization is usually not worth it. And from the skinny context of your question it does not appear to be the case. So the best is to go with above answer.
Edit (past your question edit) This is just structure and you will show it like this:

Handling composed objects in UML activity diagrams

Intro
When designing UML activity diagrams I often encounter a rather simple problem for which I have to draw a rather complicated solution. I'm looking for an UML conform shortcut or more simple solution for the following problem.
Problem
Lets assume we have a class Parent with associations to different Children:
And we have an analog Constalation with the class Result and three chidren Result Part A, etc.
Now I want to refine an activity, which accepts a Parent object as input and produces an Result as output:
In the desired refinement, I want to I want to access the children or create the result from the result parts.
Current Solution
If I want to access the children or create the result from the result parts, I always have to introduce extra activities for those rather simple tasks:
Question
Are there any shortcut or simplification here, to access, extract or merge the children of an object? The desired Solution should be legal standard UML.
Something as simple like this would be nice:
UML does not define complex object creation element. If you need to construct result object which is composition of child objects, you have to present action. You should define action with resulting pin of composed type and input pins of child object types for each one. Action can start execution only if all input pins contain expected object.
For separation of child object from composed object use transformation as it is described in Waog's answer.
In your current solution example remove join element before merge result Children action, and connect all object nodes to this action. Remove extract input Children action and use transformation.
Answer on how to split objects
I found an answer on how to split a composed object in Martin Fowlers UML distilled myself, after getting a hint from #xmojmr
The book states:
Source: UML Distilled: A Brief Guide to the Standard Object Modeling Language
By Martin Fowler - on Google Books
I still don't know, if it's allowed to omit thos transformation-notes and just draw the pins and transitions!?
Missing Answer on how to merge objects
I'm still missing the answer on how to merge objects to a composed objects without introducting a merge-activity.

Using variables in UML multiplicities

I was running a tutorial today, and a we were designing a Class diagram to model a road system. One of the constraints of the system is that any one segment of road has a maximum capacity; once reached, no new vehicles can enter the segment.
When drawing the class diagram, can I use capacity as one of the multiplicities? This way, instead of having 0..* vehicles on a road segment, I can have 0..capacity vehicles.
I had a look at ISO 1905-1 for inspiration, and I thought that what I want is similar to what they've called a 'multiplicity element'. In the standard, it states:
If the Multiplicity is associated with an element whose notation is a text string (such as an attribute, etc.), the multiplicity string will be placed within square brackets ([]) as part of that text string. Figure 9.33 shows two multiplicity strings as part of attribute specifications within a class symbol. -- section 9.12
However, in the examples it gives, they don't seem to employ this feature in the way I expected - they annotate association links rather than replace the multiplicities.
I would rather get a definitive answer for the students in question, rather than make a guess based on the standard, so I ask here: has anyone else faced this issue? How did you overcome it?
According to the UML specification you can use a ValueSpecification for lower and upper bounds of a multiplicity element. And a ValueSpecification can be an expression. So in theory it must be possible although the correct expression will be more complex. Indeed it mixes design and instance level.
In such a case it is more usual to use a constraint like this:
UML multiplicity constraint http://app.genmymodel.com/engine/xaelis/roads.jpg

Why are strings called "strings"? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
The History Behind the Definition of a 'String'
About the only thing every programming language I've seen is able to agree upon is that a variable that refers to a block of text is called a "string." Why? Where does the name come from, and how did it become idiomatic across programming in general?
Great question! This might be somewhat helpful:
Strings are called "strings" because they are made up of a sequence, or string, of characters.
Source: http://www.vias.org/cppcourse/chap07_03.html
Very interesting,
The very definition of a string (according to Princeton at least) is:
a linear sequence of symbols
So, since the String datatype is a sequence of characters/symbols, it rather fits the definition.

Resources