Generalization across Metaclasses

UML related questions and discussions

Moderator: Moderators

Generalization across Metaclasses

Postby james.ciarcia@navy.mil » Tue Aug 28, 2018 8:29 pm

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
james.ciarcia@navy.mil
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Mon Jul 24, 2017 4:15 pm

Re: Generalization across Metaclasses

Postby donatas.mazeika@nomagic.com » Thu Aug 30, 2018 9:03 am

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
donatas.mazeika@nomagic.com
Forum Expert
Forum Expert
 
Posts: 121
Posts Rating:19
Joined: Tue Apr 21, 2015 12:30 am

Re: Generalization across Metaclasses

Postby james.ciarcia@navy.mil » Thu Aug 30, 2018 9:38 am

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!
james.ciarcia@navy.mil
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Mon Jul 24, 2017 4:15 pm

Re: Generalization across Metaclasses

Postby bessiegarz68@gmail.com » Mon Jul 26, 2021 9:28 pm

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).
bessiegarz68@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Mon Jul 26, 2021 9:26 pm

Re: Generalization across Metaclasses

Postby konkesara@gmail.com » Fri Aug 13, 2021 5:40 am

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
konkesara@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Fri Aug 13, 2021 5:34 am

Re: Generalization across Metaclasses

Postby zpavel419@gmail.com » Mon Sep 06, 2021 12:18 am

is a dotted line cutting across the affected generalization with keywords in braces. ... classes, which are called metaclasses.

mcdvoice
zpavel419@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Mon Sep 06, 2021 12:17 am


Return to Software Modeling (UML)

Who is online

Users browsing this forum: No registered users and 0 guests

cron