10

I wonder if there is way to create an array of objects in UML?

the following is my try using Modelio as a modeling environment but as you can see there is different objects(i.e. instance[0],instance 1],instance[2],instance[3])

enter image description here

Sled
  • 18,541
  • 27
  • 119
  • 168
Andrew
  • 713
  • 3
  • 10
  • 19

2 Answers2

14

As you know there are two ways to show UML attributes in class diagrams: attribute text and association notation.

Consider an example of a company and employees. Two valid class diagrams are:

enter image description here

Now let's try to draw the corresponding object diagrams:

If the details of the fulltime_employees like age are important, there is no other way but to show them as separate objects:

enter image description here

If details are not important, we could go with attribute text notation:

enter image description here

Another way of showing it when number of objects is more (let's say 5 here): (This is also the general way to show multiplicities in object diagrams)

enter image description here

Hope it helps.

jurgenreza
  • 5,856
  • 2
  • 25
  • 37
0

You can use, e.g., an std::vector<Class> if you want to show a set of objects in a class diagram.

You can use instance1:Class, instance2:Class ... instanceN:Class if you want to show concrete objects, but you must add them in an object diagram, not in a class diagram.

You cannot mix elements of class diagrams and elements of object diagrams, because they are conceptually different.

Pietro
  • 12,086
  • 26
  • 100
  • 193