Book a Demo

Author Topic: PrimitiveType can be generalized, but not be specialized - why?  (Read 33888 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
I have two Float data types, say Speed and Acceleration. Two <<primitive>> Floats are compatible, but <<dataType>> Speed is not compatible to <<dataType>> Acceleration.

When I draw a Generalization from Speed to <<primitive>> Float, I read this as "Speed is a Float". And I guess this is correct. But EA 15.1 reminds me that this is not UML compliant. Why?

EA 15.1 allows to draw a Generalization from <<primitive>> Float to <<dataType>> Speed - as if each Float value is a Speed valuer - what is obviously wrong.

Am I wrong here, or has EA just lost the 50:50 game of direction?

Workaround is, to declare Speed and Acceleration as to be <<primitive>> instead of <<dataType>>.
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #1 on: August 17, 2020, 05:16:02 am »
There is no <<primitive>> Float. Only Real (see p.675 of UML 2.5).

q.

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #2 on: August 17, 2020, 02:53:46 pm »
Hi, qwerty

unfortunately your comment does not answer my question. (I am not talking about the EA built-in primitive types, but about <<primitive>> elements drawn from Toolbox Class to some Class diagram.)

To check, please create a <<primitive>> from Toolbox Class and name it Float.
Or you may select <<primitive>> Real form importing ptc-10-11-24.xmi, downloaded from omg.org, if you prefer, and substitute Float by Real in my description above.
That is not the point.

My point is, that - for what I learned - a <<primitive>> shall be the target of a Generalization relationship if related to a <<dataType>>, not the source.

A <<dataType>> can be "derived from" or "inherits from" a <<primitive>>, but not vice versa!
But EA 15.1 just offers the opposite and justifies as not UML conform if you try to drag a Generalization from a <<dataType>> to a <<primitive>> .
EA 15.1 does wrong - or I am wrong - that is what I like to find out.
Rolf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #3 on: August 17, 2020, 04:39:05 pm »
I've had a quick look in the UML 2.5 specs.

Generalization is defined as a relation between two Classifiers.
PrimitiveType --|> DataType --|> Classifier
So both are Classifiers, so from the Generalization there should not be a problem.

I also had a look at both PrimitiveType and DataType, but I see no constraints there either.

So my conclusion is that a Generalization should be allowed between DataTypes and PrimitiveTypes, regardless of the direction.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #4 on: August 17, 2020, 05:39:00 pm »
Hello all,


So my conclusion is that a Generalization should be allowed between DataTypes and PrimitiveTypes, regardless of the direction.

No, that doesn't make sense. A «primitive» has no internal structure, so you can't draw a generalization from a «primitive» to something that (potentially) does. A generalization can only add properties, it can't remove them.
I'm not entirely comfortable with a generalization targeting a primitive either (from anything but another «primitive»), though syntactically it might be allowable. I'm just not sure what it's supposed to mean.

Back to the OP, there is a problem in your data model. You can't generalize float and speed (either way). One is a data representation, the other is a mechanical property.

Floating-point and fixed-point are computer representations of real numbers. Speed is a property that an object has in relation to some other object. If you had a Mechanical Property class, then Speed could be a specialization of that. But the concept of speed is not an extension of the concept of a number.

You could choose to represent a speed as not one number but two: distance and time. That doesn't mean Speed should specialize Float twice. So instead of a generalization, your Speed class should have an attribute "value" which is of type float (or two attributes, "distance" and "time") -- but bear in mind that if you choose to use float rather than real, you are modelling data representations, not concepts. (I'm not sure which one you're aiming for.)

So Speed is not a Float. Speed contains a Float attribute, or two.

We can go further, and note that Float, if you choose to model it at all, should not be a «primitive» but a «dataType» containing the attributes "sign", "mantissa" and "exponent". This perhaps makes it easier to see why Speed is not a specialization of Float: a Speed does not itself contain a sign, mantissa and exponent; it contains a Float attribute which has those things.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #5 on: August 17, 2020, 06:00:22 pm »
The model is unit+size. Unit can be speed, weight, and so on. Size can be Int, Real, Complex, a textually described range (like low and high). It's not a melange of unit and size. Ask any physicist.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #6 on: August 17, 2020, 06:08:28 pm »
Hello all,


So my conclusion is that a Generalization should be allowed between DataTypes and PrimitiveTypes, regardless of the direction.

No, that doesn't make sense. A «primitive» has no internal structure, so you can't draw a generalization from a «primitive» to something that (potentially) does.
I'm not saying it makes sense. I'm saying the UML syntax allows it.
Quote
A generalization can only add properties, it can't remove them.
If that is true then the generalization from PrimitiveType to Datatype in the UML metamodel is wrong as well.
There it states:
Quote
A PrimitiveType defines a predefined Datatype, without any substructure
So it is effectively taking things (the substructure) away instead of adding it.

Feels wrong to me as well  :-X

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #7 on: August 17, 2020, 06:39:42 pm »
Well, I think the words are wrong/ambiguous/not in the same context...

When we say Generalization, do we mean UML Generalization which IIRC is "the wrong way round", or do we mean natural language Generalization?  ArchiMate Specialization is "the correct way round".

But it is not congruent with natural language use of Specialization.  IIRC it is inheritance, whereas natural language specialization allows for both inheritance and restriction  (IS_A_TYPE_OF and IS_WHERE).

The infamous "Object-Oriented Software Construction" allows for specializations (inheritance) to not inherit all properties (so long as it inherits the bulk).  "Madam, we've established what you are. Now we're just arguing the price."

In my view, a Primitive (data) type cannot be further decomposed, otherwise, it confounds the concept of "primitive"  ("being the first or earliest of the kind or in existence"). A (non-primitive) datatype can be composed of one or more primitive types (and/or one or more non-primitive datatypes).  Define the relationships consistently (from first principles) and your answer should "pop out".

Paolo

(Lights blue touch-paper and runs...  :o)
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #8 on: August 17, 2020, 06:53:14 pm »
So my conclusion is that a Generalization should be allowed between DataTypes and PrimitiveTypes, regardless of the direction.
No, that doesn't make sense. A «primitive» has no internal structure, so you can't draw a generalization from a «primitive» to something that (potentially) does.
I'm not saying it makes sense. I'm saying the UML syntax allows it.
It doesn't allow it. If you look in chapter 10.2 DataTypes (in UML 2.5), PrimitiveType and Enumeration are specializations of DataType, which is in turn a specialization of Classifier. DataType has two aggregations to Property and Operation, but those are not inherited down.

The MOF spec 1.4.1 included the following language (6.3.1.5 Class Generalization):
The meaning of MOF Class generalization is similar to generalization in UML and to interface inheritance in CORBA IDL. The sub-Class inherits all of the contents of its super-Classes (i.e., all of the super-Classes Attributes, Operations and References, and all nested DataTypes, Exceptions, and Constants).

Note the absence of Assocation and Aggregation in this list. If Property and Operation had been attributes of DataType, they would have been inherited. But they're aggregates, and as such are not inherited.
Subsequent versions of the MOF spec have dropped this language, but I can't find anything that supports the idea that MOF generalization was ever extended to include aggregations.
Quote
Quote
A generalization can only add properties, it can't remove them.
If that is true then the generalization from PrimitiveType to Datatype in the UML metamodel is wrong as well.
There it states:
Quote
A PrimitiveType defines a predefined Datatype, without any substructure
So it is effectively taking things (the substructure) away instead of adding it.
See above.

(God, I hope I'm right about this...)


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #9 on: August 17, 2020, 07:06:25 pm »
The MOF spec 1.4.1 included the following language (6.3.1.5 Class Generalization):
The meaning of MOF Class generalization is similar to generalization in UML and to interface inheritance in CORBA IDL. The sub-Class inherits all of the contents of its super-Classes (i.e., all of the super-Classes Attributes, Operations and References, and all nested DataTypes, Exceptions, and Constants).
Note the absence of Association and Aggregation in this list. If Property and Operation had been attributes of DataType, they would have been inherited. But they're aggregates, and as such are not inherited.
Subsequent versions of the MOF spec have dropped this language, but I can't find anything that supports the idea that MOF generalization was ever extended to include aggregations.
Hmm, never thought of it like that. Although, if not Associations, what would they mean with "References"?

But that was more of a side remark.
Do you agree that the UML syntax allows Generalizations between PrimitiveType and Datatype because they are both Classifiers?

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #10 on: August 17, 2020, 07:55:21 pm »
Even if syntactically correct: the semantics is not correct. Generalization is used more wrong than right. My favorite: an amphibious vehicle does not inherit from car and boat. It's a class of its own.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #11 on: August 17, 2020, 08:08:11 pm »
Even if syntactically correct: the semantics is not correct. Generalization is used more wrong than right. My favorite: an amphibious vehicle does not inherit from car and boat. It's a class of its own.

q.
Sure, but I would expect an UML tool to validate the syntax of my UML model, not the semantics.

I think that EA should allow generalizations between DataTypes and Primitivetypes in any direction if that is allowed by the UML syntax.

If we leave it up to EA to interpret and validate the semantics as well, I'm afraid we'll end up on a slippery slope.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #12 on: August 17, 2020, 10:05:25 pm »
The MOF spec 1.4.1 included the following language (6.3.1.5 Class Generalization):
The meaning of MOF Class generalization is similar to generalization in UML and to interface inheritance in CORBA IDL. The sub-Class inherits all of the contents of its super-Classes (i.e., all of the super-Classes Attributes, Operations and References, and all nested DataTypes, Exceptions, and Constants).
Note the absence of Association and Aggregation in this list. If Property and Operation had been attributes of DataType, they would have been inherited. But they're aggregates, and as such are not inherited.
Subsequent versions of the MOF spec have dropped this language, but I can't find anything that supports the idea that MOF generalization was ever extended to include aggregations.
Hmm, never thought of it like that. Although, if not Associations, what would they mean with "References"?

Again from MOF 1.4.1 (pp 18-19):
"The MOF Model provides an additional kind of Class feature called a Reference that provides an alternative “Attribute like” view of Associations."
This is in addition to associations and attributes, and they provide an example. It is a bit of a weird one, but the point is that it's a different beast from either attributes or associations.

Quote
But that was more of a side remark.
Do you agree that the UML syntax allows Generalizations between PrimitiveType and Datatype because they are both Classifiers?

No.

If that were the case then all relationships that pertain to Classifier would apply equally to all subtypes of Classifier. This would mean that actors could generalize use cases, collaborations could redefine enumerations, etc.

In fact, since Classifier itself is a specialization, if you go all the way up to the root concepts, you'll find that that line of reasoning eradicates all but the most fundamental distinctions in UML. Since all elements are ultimately specializations of Element, and all relationships are ultimately specializations of Relationship, and since Elements can have Relationships to other Elements, all UML elements can have all UML relationships to all other UML elements. This is clearly nonsense.

The key, I believe, lies in the fact that Classifier is abstract. While Generalization (which is concrete) is defined as having one directedRelationship from one "specific" Classifier, and one directedRelationship to one "general" Classifier, this doesn't mean that all specializations of Classifier can be substituted freely. Only concrete specializations can be the source/target of those relationships, and I think the correct way to read figure 9.1 is to say that they must both be the same, ie a Generalization is only valid between two of the same specialization of Classifier. But since Generalization is concrete, we don't need to specialize it into different relationships for ClassGeneralization, ActorGeneralization, etc.

In the DataType case, this means that you can draw Generalizations between two DataTypes, between two Enumerations and between two Primitives, but nothing else.
You should also be able to draw Generalizations between two Classes, but not between a Class and an Interface. And so on.

EA does allow quite a lot of these cross-classifier-specialization generalizations. I think it's wrong in each case.


/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #13 on: August 17, 2020, 10:52:40 pm »
The key, I believe, lies in the fact that Classifier is abstract. While Generalization (which is concrete) is defined as having one directedRelationship from one "specific" Classifier, and one directedRelationship to one "general" Classifier, this doesn't mean that all specializations of Classifier can be substituted freely. Only concrete specializations can be the source/target of those relationships, and I think the correct way to read figure 9.1 is to say that they must both be the same, ie a Generalization is only valid between two of the same specialization of Classifier. But since Generalization is concrete, we don't need to specialize it into different relationships for ClassGeneralization, ActorGeneralization, etc.

In the DataType case, this means that you can draw Generalizations between two DataTypes, between two Enumerations and between two Primitives, but nothing else.
You should also be able to draw Generalizations between two Classes, but not between a Class and an Interface. And so on.

EA does allow quite a lot of these cross-classifier-specialization generalizations. I think it's wrong in each case.


/Uffe

That makes a lot of sense, thanks Uffe for your excellent explanation.
I think I agree with you.
EA should limit Generalizations and allow only source and target of the same metatype.

I'm curious to Eve's opinion on this topic. (She's usually the one who corrects us and tells us EA was right all along ;))

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: PrimitiveType can be generalized, but not be specialized - why?
« Reply #14 on: August 18, 2020, 08:32:04 am »
As predicted, here I am.

9.9.4.7 - Operations (for Classifier)
Quote
maySpecializeType(c : Classifier) : Boolean
The query maySpecializeType() determines whether this classifier may have a generalization relationship to
classifiers of the specified type. By default a classifier may specialize classifiers of the same or a more general
type. It is intended to be redefined by classifiers that have different specialization constraints.
body: self.oclIsKindOf(c.oclType())

There's a matching constraint that uses this operation, but I hope you get the idea. Interestingly, I'm not aware of any redefinitions of this rule, except for those that extend the same idea to stereotypes. (eg. a SysML block has the same constraint to its specializations) It's actually common enough that the metamodel relationships allow you to create stereotyped relationship that follows it by linking to a metaclass with the name "source.metatype.general".

"source.metatype.general"