Book a Demo

Author Topic: Tagged Values vs Attributes - when to use what?  (Read 10740 times)

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Tagged Values vs Attributes - when to use what?
« on: October 31, 2012, 11:32:26 am »
Hi. I'm a bit confused re: Tagged Values - what's the actual purpose for these? Seems like they can be used in the exactly the same fashion as attributes. When should tagged values be used vs attributes? Are there any advantages / disadvantages to them?

Thanks,

Vlad

MREA

  • EA User
  • **
  • Posts: 72
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #1 on: October 31, 2012, 05:24:31 pm »
Well I understood this like that

Attributes are normal attributes like : int, struct, enum, string,...
Tagged values are further informations for that attribute
like for struct or enum or type def. "type_synonyms"
so you get
               struct {
               } name1,name 2,name 3 (taggs)

you also can mark structs as "typedef=true" to say you wanna have a type def too, hope I helped
Support- Languages: German, English, French

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #2 on: October 31, 2012, 08:37:04 pm »
There's no big semantic difference between both. As MREA said the attributes are meant for more technical purpose. That is, they will be transformed to bits and bytes while tags convey more human readable information.

YMMV

q.

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #3 on: November 01, 2012, 01:35:36 am »
Are tag names / values searchable? Eg, when I create Relationship Matrix? Seems like they are not...

MREA

  • EA User
  • **
  • Posts: 72
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #4 on: November 01, 2012, 01:40:39 am »
what you mean with searching?
you mean with CTRL+F ?
try extended
Support- Languages: German, English, French

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #5 on: November 01, 2012, 02:16:26 am »
Quote
Are tag names / values searchable? Eg, when I create Relationship Matrix? Seems like they are not...
Not in the RM. As MREA points out you can used the Extended search from Ctrl-F or you write your own search like
Code: [Select]
SELECT
  o.ea_guid AS CLASSGUID, o.Object_Type As CLASSTYPE, o.Name, p.property, p.value
FROM t_object o
INNER JOIN t_objectproperties p ON o.object_id = p.object_id
(from my book Inside EA).

q.
« Last Edit: November 01, 2012, 02:17:30 am by qwerty »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #6 on: November 01, 2012, 10:38:30 am »
Attributes and tagged values are very different things. Attributes are properties of a class. When you generate code from your model, they will become member variables. Tagged values, on the other hand, are a way to extend UML. For example, you may want to add a review status to each message on a sequence diagram. UML has nothing to say on the subject of review statuses, so you add a tagged value to all your messages.

Attributes are part of what you are modeling; tagged values are part of how you are modeling.
« Last Edit: November 01, 2012, 11:20:05 am by KP »
The Sparx Team
[email protected]

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #7 on: November 02, 2012, 12:26:22 am »
Still not very clear to me... Here is a concrete example: I need to model a deployment Node, which represents an execution environment. Each execution environment can run either 'real' or 'artificially generated' data. Also, the environments can be targeted to be used for different purposes: production, test, dev, project specific, etc. Should i be using tags or attributes to describe all these features associated with environment?

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #8 on: November 02, 2012, 01:17:13 am »
I think for this case you should use tagged values to specify the purpose of the actual node. IMHO attributes would be more appropriate to model the (relevant) hardware/software properties of this node.

On the other hand if you use attributes to describe these characteristics, you can build diagrams using instances(!) of such nodes, where you fill in concrete values.

It depends a bit of what's your purpose, for e.g. programming language related classes its pretty clear as KP describes it. In this case tagged values would be used to specify meta information for attributes (e.g. programming language language characteristics like 'volatile' that aren't supported directly in UML).

HTH,
Günther
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #9 on: November 02, 2012, 02:31:33 pm »
IMHO
In meta model, a stereotype (e.g. named as A)'s attribute will become its instance's (stereotyped by A)  tagged value. The instance of A is a classifier (e.g. named as B). Then instance of B is an object, its slot can dynamically play the role as B's attribute; but can not change B's tagged value.

For example,
1. In meta model, create a stereotype "Car" with an attribute "transmissionKind", value can be enumerated as "auto" or "manual".

2. On Class diagram, create three classes:
     <<Car>>AutoCar, whose tag "transmissionKind" is set as "auto";
     <<Car>>ManualCar, whose tag "transmissionKind" is set as "manual";
     <<Car>>CVTManualCar, whose tag "transmissionKind" is set as "manual"; add another tag "CVT", whose value is true (or "manualType", whose value is "CVT"; whatsoever...)

3. All AutoCar, ManualCar and CVTManualCar were added following attributes:
     leftFront: Wheel
     leftRear: Wheel
     rightFront: Wheel
     rightRear: Wheel
     transmission: Transmission

4. Now if I create an object "MyCar", typed by "CVTManualCar", then
     It will definitely be a "CVT manual" car, no chance to be an "auto" car, no chance to be other type of manual car.
     But I have the right to change wheels:
        Michelin / leftFront: Wheel
        Funlop / leftRear: Wheel
        FireStone / rightFront: Wheel
        HomeMade / rightRear: Wheel
     And have the right to choose a CVT Manual Transmission
        Shimano / transmission: Transmission

5. When do code generation, something like:
class CVTManualCar
{
     Wheel* leftFront;
     Wheel* leftRear;
     Wheel* rightFront;
     Wheel* rightRear;
     Transmission* transmission;
}

Pardon, how to use the "transmissionKind" tag? It can be used in the code generation template like this way (pseudo):
%if tag.transmissionKind.value == "auto"%
       AutoTransmisson* transmission;
%else if tag.transmissionKind.value == "manual"%
       ManualTransmission* transmission;
%    if tag.CVT.value == "true"%
           CVTManualTransmission* transmission;
%    end if%  
%end if%

Note: class "Transmission" is generalized by "AutoTransmisson" and "ManualTransmission", which is further generalized by "CVTManualTransmission".

Maybe it is an ugly design, but it demonstrated how tag value are used in code generation.

Quote what KP said "Attributes are part of what you are modeling; tagged values are part of how you are modeling."

 ;)
« Last Edit: November 02, 2012, 03:25:38 pm by milesma »

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #10 on: November 03, 2012, 04:48:05 am »
Thanks - that's a really good explanation. Sparx docs would definitely benefit if this kind of info is incorporated there. I have a followup question re: this statement though:

Quote
It will definitely be a "CVT manual" car, no chance to be an "auto" car, no chance to be other type of manual car.

I modeled a new stereotype like you mentioned. Defined the value of the tag in the classifier. But I still could 'redefine' this value in the instantiation of that classifier. When I change the value of the tag in the instance, Sparx seem to create a 'copy' of that tag in a separate section. So I end up with two sections in the 'MyProfile' section of my instantiation:

Code: [Select]
---------
MyProfile::Car (MyCar)
    transmissionKind: auto  ---> this is the value I redefined for the MyCar instantiation of CVTManualCar classifier
---------
from CVTManualCar
    MyProfile::Car
         transmissionKind: manual ----> this is the value defined for the CVTManualCar classifier

So, if I understand it correctly, I CAN change the transmission type of my CVTManualCar for the particular MyCar instance...

Thanks!


MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #11 on: November 04, 2012, 12:32:33 am »
EA has the ability to create tag for the instance to overwrite the classifier's tag value (I'm not sure it is intentional or not, maybe some customer requested that). At least, it is correct that you can not change the classifier's tag value from its instance. I think that's enough.

Personally, I don't like to add tag value or attribute to an object. For instance of classifier, it only cares "run state", which is the slot play the role of its classifier's property(aka attribute).


volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Tagged Values vs Attributes - when to use what
« Reply #12 on: November 05, 2012, 04:51:55 am »
Ok. Thx.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Tagged Values vs Attributes - when to use what
« Reply #13 on: November 05, 2012, 08:16:22 pm »
I'm not sure of this is going to help, but you should consider tagged values as "meta" attributes.

They are very much the same thing as the notion "IsAbstract", "Type","OwnedProperties", "Name". All of these things are attributes of the metaclass Class, and can be filled in in an instance of this metaclass (the actual class in your model).

Tagged values offer a way to extend UML and add your own properties to UML elements. (in case you need more then the standard Name, Type,...)

If you have trouble deciding which one to use, you're doing something wrong.

Geert