Page 1 of 1

Generalization across Metaclasses

PostPosted: Tue Aug 28, 2018 8:29 pm
by james.ciarcia@navy.mil
The generalization relationship is defined in UML 2.5 as a relationship between 2 Classifier metaclasses. See section 9.2.2 for Abstract Syntax, 9.2.3.2 for Semantics and 9.9.7 for Classifier Description. There is no statement that restricts Generalization relationships between different specializations of Classifier as far as I can tell in the specification. However I was not able to create Generalization relationships between certain specializations, while I was able for others.

I was unable to generalize a Class to an Actor, which was my primary concern.
I was able to generalize Node to a Class.
I was able to generalize Component to a Class.
I was unable to generalize Node to Component or visa-versa.

Is there a rhyme or reason to why CSM allows some Generalizations across metaclasses, but not others? Why is CSM more restrictive than the UML specification?

Do stereotypes influence how Generalization works or doesn't? I don't think it should unless there is a specific Constraint declared in the Specification for those stereotypes.

I performed the tests in both CSM 18.5 SP3 and CSM 19.0

Re: Generalization across Metaclasses

PostPosted: Thu Aug 30, 2018 9:03 am
by donatas.mazeika@nomagic.com
Hello,

UML specification does not allow this. Please see Classifier section > Constraint:
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())


Best regards,
Donatas Mazeika

Re: Generalization across Metaclasses

PostPosted: Thu Aug 30, 2018 9:38 am
by james.ciarcia@navy.mil
Donatas,

Thanks for the reply and pointing to the Classifier Constraints and Operations. That was exactly the information I was looking for even if it wasn't the answer I was hoping for. Thanks!

Re: Generalization across Metaclasses

PostPosted: Mon Jul 26, 2021 9:28 pm
by bessiegarz68@gmail.com
Use of metaclasses is an example of the latter. 99% of the time, you don't need or want to use them. But there are very rare cases when introducing the complexity of a metaclass is better than the alternative, complicated solution (which often involves using a hundred nested if/elif/else or try/except/finally statements, and/or the dreaded eval).

Re: Generalization across Metaclasses

PostPosted: Fri Aug 13, 2021 5:40 am
by konkesara@gmail.com
is a dotted line cutting across the affected generalization with keywords in braces. ... classes, which are called metaclasses.
Thanks for sharing such a helpful instruction, really appreciate for your article.

dgcustomerfirst

Re: Generalization across Metaclasses

PostPosted: Mon Sep 06, 2021 12:18 am
by zpavel419@gmail.com
is a dotted line cutting across the affected generalization with keywords in braces. ... classes, which are called metaclasses.

mcdvoice