Book a Demo

Author Topic: Class instances  (Read 21925 times)

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Class instances
« on: June 20, 2014, 01:24:23 pm »
I am trying to create instances of UML Classes using the "Object>Advanced>Set Run State" property and have run into two problems:
1. "Set Run State" only allows a single value, therefore multiple values cannot be det where the cardinality of the Class property is >1
2. Properties of associations do not appear as Variables in the "Set Run State" dialogue.

Is there another way that values associated with instances can be specified apart from "Set Run State" (or Notes attached to empty Objects)?
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #1 on: June 20, 2014, 05:22:34 pm »
1. That means you have multiple instances. So you set the state in each instance.
2. That is because you have run states to visualize the concrete values those attributes can take. For that very reason the Set Run State offers the attributes declared in the classifier.

q.
« Last Edit: June 20, 2014, 05:22:46 pm by qwerty »

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #2 on: June 23, 2014, 09:02:49 am »
> 1. That means you have multiple instances. So you set the state in each instance.
Not necessarily. For example I want to create a single instance of a 'RequirementsClass' that has multiple 'Requirements'.
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #3 on: June 23, 2014, 03:46:30 pm »
And what would Requirements be? An attribute collection?

q.

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #4 on: June 23, 2014, 03:55:18 pm »
I'm not sure what an "Attribute Collection" is, but it sounds right.
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #5 on: June 23, 2014, 04:51:06 pm »
You could say: array. But honestly, you should explain what you mean by
Quote
'RequirementsClass' that has multiple 'Requirements'
Maybe that would help to clarify your issue.

q.

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #6 on: June 23, 2014, 05:00:25 pm »
For a simple RequirementsClass with 2 attributes: name (1..1) and requirement (1..*) an 'instance' of the Requirements Class is:
Attribute 'name' =      "/req/xsd-xml-rules"
Attribute 'requirement' =      "/req/xsd-xml-rules/time-zone"
Attribute 'requirement' =      "/req/xsd-xml-rules/unit-of-measure"
Attribute 'requirement' =      "/req/xsd-xml-rules/swe-types"

Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #7 on: June 23, 2014, 05:12:28 pm »
So you are talking about xsd modeling. There are quite some constraints when you are tempting that. xsd can model more than UML can do. It's like an incompatibility in proverbs in different languages (like e.g. in UK you kill two birds with a stone, but in Germany you kill two flies with a flyswatter). For that reason you need to stick to some constraints and limit what you should express in xsd.

The Attribute 'name' is directly mapped to the UML element property 'name' - implicitly and logically. The Attribute 'requirement' could be mapped to tagged values named 'requirement' each carrying the values. You could also map these associated to a 'requirement' element named with the value shown after the equation. There is actually no default or standard for that. If you google for "xsd uml mapping" or the like you should get some results (I got a nice PDF as first result but that depends on the searcher).

q.
« Last Edit: June 23, 2014, 05:14:09 pm by qwerty »

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #8 on: June 24, 2014, 08:34:59 am »
The examples had pathnames related to xsd but that was just the content and not related to the issue.
Alternative example:
Attribute 'name' =      "requirement class 1"
Attribute 'requirement' =      "requirement 1"
Attribute 'requirement' =      "requirement 2"
Attribute 'requirement' =      "requirement 3"
It makes no difference using either Tagged Values or elements, it requires multiple entries for a single  "requirement" Tagged value or element. A similar problem to only having a single run state.
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #9 on: June 24, 2014, 09:05:06 am »
So what you are modeling is a collection. You should set the multiplicity of the 'requirement'  attribute to something greater than one. Like this:

But to be honest, I do not have the faintest idea what you are doing there

q.
« Last Edit: June 24, 2014, 09:06:16 am by qwerty »

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #10 on: June 24, 2014, 10:01:54 am »
Yep - that's what I'm after.
So how do I take Class1 in a Class Diagram with "a: string [1..*]" (rather than "a:int [1..10] in your example) and generate an instance:
:Class 1
a(0) = string 1
a(1) = string 2
 ... etc?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Class instances
« Reply #11 on: June 24, 2014, 06:50:03 pm »
Simply add an attribute of type string to your class. You need to apply the multiplicity in the Detail tab in a second step after you have saved the attribute name.

The run state is the set manually in the object via Advanced/Set Run State.

q.
« Last Edit: June 24, 2014, 06:50:37 pm by qwerty »

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #12 on: June 25, 2014, 10:11:49 am »
One of us is missing something here.
1. I have a Class (e.g. Class_1)
2. It has an attribute (e.g. Attribute_1)
3. The Attribute has a DataType (e.g. CharacterString)
4. The Attribute has multiple cardinalities (e.g. [1..*]
5. I can set the Run State for an instance but only for one value of Attribute_1.
The question is (see first post) how to instantiate Class_1 with multiple entries for Attribute_1.
Bruce

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Class instances
« Reply #13 on: June 25, 2014, 10:30:19 am »
I would probably add separate run state variables for each array item, e.g.
Code: [Select]
attribute_1[0] = "value1"
attribute_1[1] = "value2"
attribute_1[2] = "value3"
...

Alternatively, you can have a single run state variable with value expressed as a list, e.g.
Code: [Select]
attribute_1 = "value1","value2","value3",...
The Sparx Team
[email protected]

BruceS

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Class instances
« Reply #14 on: June 25, 2014, 10:52:01 am »
The Class has an attribute with multiple cardinality but the Instance run state only allows a single value for that attribute.
How do I "add separate run state variables for each array item"?
Bruce