Book a Demo

Author Topic: Inheritability of stereotypes  (Read 12782 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Inheritability of stereotypes
« on: May 09, 2005, 07:40:25 am »
The UML 2.0 specification appears to be silent on the matter,
but why aren't stereotypes inherited along with attributes and
operations?  ???

In fact, the default filter for stereotypes should be: show all
base class stereotypes

While we're at it, shouldn't stereotypes have visibility like
attributes?  :-)


Quote
From the UML 2.0 Glossary:
[size=13]Stereotype:[/size]
A class that defines how an existing metaclass (or
stereotype) may be extended, and enables the use of platform or
domain specific terminology or notation in addition to the ones
used for the extended metaclass. Certain stereotypes are
predefined in the UML, others may be user defined. Stereotypes
are one of the extensibility mechanisms in UML.


While, the definition is correct, the implications of the
definition are not obvious, in my view... While the stereotype
is defining the extension of the metaclass (or stereotype), you
apply the denomination to an instance of the class...  That is,
although the stereotype «enumeration» extends class, all the
definition says its that you may apply the stereotype
«enumeration» to a class.  Not every class is an
«enumeration».  Now supposing I make class X an
«enumeration», then it seems to me from first principles, that
all subclasses of X must also be «enumeration»s.  

In addition, in my verbaliser technology, that I have
implemented in Rational Rose, I explicitly inherit stereotypes
and I have found it most useful in determining the validity of
the model.  After you enforce stereotype inheritance, you may
find stereotypes appearing in what appear to be inappropriate
parts of the model.  (Coupling this with stereotype adornments
that help them stand out)  

When you investigate, you find that there is an ERROR in the
model!  Fix the error, the inappropriate stereotype is removed
and all is right with the world!  ;D

Thoughts anyone?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Evil_Genius

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Inheritability of stereotypes
« Reply #1 on: May 10, 2005, 02:43:05 am »
Quote
The UML 2.0 specification appears to be silent on the matter,
but why aren't stereotypes inherited along with attributes and
operations?  ???

Here's an example: suppose you have a class hierarchy and you want to mark the root node with the <<root>> stereotype. Do you really want stereotypes to be inherited?

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #2 on: May 10, 2005, 04:23:40 am »
Quote
Here's an example: suppose you have a class hierarchy and you want to mark the root node with the <<root>> stereotype. Do you really want stereotypes to be inherited?


Interesting point Evil... 8)  I'll have to think about it.  My first impression, though, is that <<root>> might not be an appropriate use of stereotype.  I would have thought the stereotype needs to indicate something innate in the class, which, I suspect, in this instance it doesn't.
Can you explain the semantics of <<root>>.   (I've found the "bleeding obvious" often isn't- that's why I haven't injected any semantics of my own yet).  How is the existing metaclass extended by <<root>>?

As a side issue, do you have any thoughts about stereotype hierarchies?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Inheritability of stereotypes
« Reply #3 on: May 10, 2005, 06:23:31 am »
Quote
any stereotype that applies to a specific class in the metamodel also applies to any subclasses of that class:
...from various Google-obtained pages.

So it's really a case of EA deciding to show them as such.

Multiple inheritance from stereotyped classes , anyone ?

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Inheritability of stereotypes
« Reply #4 on: May 10, 2005, 06:28:03 am »
Since there can only be one stereotype to an element it seems a bit restrictive to make it part of the inheritable features...
Besides an stereotype is an abstract concept, like a metaclass or a class... you should be able to create a stereotype that inherits from another one, but not a class that has a stereotype as a father (meaning that a class that has a stereotype is no longer a class but a stereotype of that class)...
Attributes and methods are physical characteristics of a class, the stereotype is more etheral.
I know it sounds abstract, but i am trying to 'land' it and can't find the proper words... i will try to think of a better way to phrase it latter.
Anyways, it feels correct to me...

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Inheritability of stereotypes
« Reply #5 on: May 10, 2005, 06:34:48 am »
Quote
...from various Google-obtained pages.

So it's really a case of EA deciding to show them as such.

Multiple inheritance from stereotyped classes , anyone ?


I think that is it, the inheritable feature is the "ability" to adopt that stereotype, but there is still only one stereotype to each element and so it can't be in the nature of the child to have it father's stereotype.
A stereotype stills seems to me more like a behavior characteristic than a structure or physicall one so i'm trying to look at it like a class behavior pattern... perhaps it could be an overwrittable one...
« Last Edit: May 10, 2005, 06:35:51 am by Alexander »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #6 on: May 10, 2005, 01:16:10 pm »
Quote

...from various Google-obtained pages.
Quote


Mike,  did you check the source of those pages?  I may have written them...
;D

(Only kidding!)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #7 on: May 10, 2005, 01:19:17 pm »
Quote
Since there can only be one stereotype to an element it seems a bit restrictive to make it part of the inheritable features...


Sorry Alexander, in UML 2 you can (AT LAST!) have more than one stereotype per element!  8)  That's what started me thinking about this...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #8 on: May 10, 2005, 01:22:38 pm »
Quote
...(meaning that a class that has a stereotype is no longer a class but a stereotype of that class)...


No... it's a stereotyped class...  We have to be very careful (and clear) about this...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #9 on: May 10, 2005, 01:33:03 pm »
Quote
Attributes and methods are physical characteristics of a class, the stereotype is more ethereal.

(It's not bash Alexander day - honest! :D)

But here I can definitely agree with you!  Much as I might like to have stereotypes add attributes and operations, they can't!  That's the job of Generalization!
 
I also agree with you  that the stereotype is more ethereal.  It "hints at" differences in processing or behaviour within the same class.  That's why you can use it to add tagged values, and why you can get different adornments to the class.   (EA doesn't yet support that ability of stereotypes does it?  Other products do.) :(

You're NOT changing the intrinsic structure or contracts of the class, but how it might respond.

In the light of this view (approach) can you see how Inheritability of stereotypes becomes more reasonable?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Evil_Genius

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Inheritability of stereotypes
« Reply #10 on: May 11, 2005, 02:26:05 am »
Quote

Interesting point Evil... 8)  I'll have to think about it.  My first impression, though, is that <<root>> might not be an appropriate use of stereotype.  I would have thought the stereotype needs to indicate something innate in the class, which, I suspect, in this instance it doesn't.
Can you explain the semantics of <<root>>.


Oh I dunno, it was just the first example that came to mind. Perhaps you could be generating a custom language and the syntax of root nodes is different to other nodes - the stereotype is used to modify the code generation templates. I think that's a perfectly valid use for stereotypes. You could also do it with a tagged value, but applying tagged values to elements is another valid use for stereotypes. Either way, stereotypes aren't "properties", so they aren't inherited.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #11 on: May 11, 2005, 05:20:43 am »
Quote
Perhaps you could be generating a custom language and the syntax of root nodes is different to other nodes - the stereotype is used to modify the code generation templates.  I think that's a perfectly valid use for stereotypes.

Using stereotypes to modify code generation IS indeed a valid use for stereotypes.  I'm not sure if it's explicitly stated in the UML 2 specifications, but it's certainly implied.
Nevertheless, I still suspect your usage is novel...

Quote
You could also do it with a tagged value, but applying tagged values to elements is another valid use for stereotypes.

It's actually a required UML 2 functionality which EA isn't yet implmenting... ;)

Quote
Either way, stereotypes aren't "properties", so they aren't inherited.

The actual term used in the UML 2 is "feature".  Your point is taken for strict UML 2.  My question is "beyond" current UML.  I guess I'm proposing that stereotypes (and any associated characteristics like adornment and tagged values) be treated as "features"

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Inheritability of stereotypes
« Reply #12 on: May 11, 2005, 05:52:54 am »
Quote
(It's not bash Alexander day - honest! :D)

But here I can definitely agree with you!  Much as I might like to have stereotypes add attributes and operations, they can't!  That's the job of Generalization!
  
I also agree with you  that the stereotype is more ethereal.  It "hints at" differences in processing or behaviour within the same class.  That's why you can use it to add tagged values, and why you can get different adornments to the class.   (EA doesn't yet support that ability of stereotypes does it?  Other products do.) :(

You're NOT changing the intrinsic structure or contracts of the class, but how it might respond.

In the light of this view (approach) can you see how Inheritability of stereotypes becomes more reasonable?

Paolo



That was what i was trying to say when refering to stereotypes as 'etheral' and to attributes and methods as 'physical'

I wasn't aware that you could have more than one stereotype in UML 2.0, i would have to think about that, it sure makes me think there is a 'multiple inherit' problem there since it defines multiple behavior for probably the same characteristic.

Just to be clear, i never said stereotype Inheritability wasn't reasonable, my point was it would bring a lot of 'inconsistency' to the UML model (i would have to review this in the light of recent information).

This might be a very dumb question, but how do you plan to inherit a class from another if not by the use of 'generalize'?

Don't worry about 'bash Alexander day', my girlfriend stablished it as a permanent festivity long ago  ;)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Inheritability of stereotypes
« Reply #13 on: May 11, 2005, 06:02:14 am »
Quote
This might be a very dumb question, but how do you plan to inherit a class from another if not by the use of 'generalize'?

My point was Generalization in UML is the method by which attributes and operations (features) get passed down.  I didn't explain myself well enough, sorry...

Quote
Don't worry about 'bash Alexander day', my girlfriend established it as a permanent festivity long ago  ;)

Say no more!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Evil_Genius

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Inheritability of stereotypes
« Reply #14 on: May 12, 2005, 03:48:58 am »
Quote

The actual term used in the UML 2 is "feature".

Of course, apologies, feature is indeed le mot juste. It was on the tip of my tongue, honest!

Quote
Your point is taken for strict UML 2.  My question is "beyond" current UML.  I guess I'm proposing that stereotypes (and any associated characteristics like adornment and tagged values) be treated as "features"


I hope they never are. If stereotypes aren't inherited, you can choose to apply them wherever you wish; if they are inherited, you can no longer choose not to apply them.