Book a Demo

Author Topic: What and How should things get Specialized?  (Read 10471 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
What and How should things get Specialized?
« on: July 10, 2005, 11:30:15 pm »
Hi,

Following my posts on:It's pretty obvious I'm interested in Generalization/Specialization/Inheritance.

This thread is about discussing what and how should things be inherited when we connect two classes with the Generalization connector.

First, a few (hopefully normative) definitions.  If we can't agree on the definition, then they are what we should discuss, not the consequences therefrom.  Once we agree on the definitions, we can discuss the issues.

The UML 2 Superstructure Specification (abridged):
Quote
7.3.20 Generalization (from Kernel, PowerTypes)
A generalization is a taxonomic relationship between a more general classifier and a more specific classifier. Each instance of the specific classifier is also an indirect instance of the general classifier. Thus, the specific classifier inherits the features of the more general classifier.
Description:
A generalization relates a specific classifier to a more general classifier, and is owned by the specific classifier.
Semantics:
Where a generalization relates a specific classifier to a general classifier, each instance of the specific classifier is also an instance of the general classifier. Therefore, features specified for instances of the general classifier are implicitly specified for instances of the specific classifier. Any constraint applying to instances of the general classifier also applies to instances of the specific classifier.

This definition sounds good enough to me - although the impact of the definition isn't always clear (to me).

The key point about the definition is that the specialized classifier is an implicit or indirect occurrence of the generalized classifier.  Thus we can correctly say (in English) the descendant inherits the characteristics of the antecedent (ancestor).  Or the child inherits from the parent.  The inheritance manifests itself in the availability of the current feature signature and implementation in the parent to the child.

Because of the different ways in which the different languages manage Inheritance, I'm going to use a more generic set of concepts - which I'll define as I go along.

First of all, we need to recognise that the definition provides for an inheritance hierarchy.   By convention, we place the ancestors toward the "top" of the hierarchy and the descendants toward the bottom - which requires we understand that anything that is defined higher up the hierarchy is available to everything lower down the hierarchy.  This is also true of multiple inheritance.

In order for a feature (defined later) to be made available to a child, it must have it's signature (to be defined later) defined in the parent.  That is, we must know enough about the feature to be able to reference it in the child.

Once defined, a feature can be given effect (implemented or effected).  For any given descendant, the process of making the feature available is by (upward) traversal of the hierarchy until an effected definition of the feature is found in an ancestor.  That version of the feature is made available to the descendant.

A descendant may chose it's own version of the feature by one of a number of methods:
  • Redefining - where the signature of the feature is changed.  By implication, the feature is also reeffected.
  • Reeffecting - where the signature remains the same, but the implementation is changed.  If the feature has only been previously defined (usually designated abstract), this is usually known as implementing; if already implemented, this is known as overriding.
  • Undefining - where the definition is no longer available (to the descendant or its children).
  • Renaming - where the name is changed (for this descendant and its children)

If you are having difficulty visualising some of these concepts, EA itself can help you!  If you pick a class on a diagram for which you know there are ancestors, and use Set feature visibility (Ctrl-Shift-Y) to enable ALL the actual and inherited features, then EA current does a useful (but not complete job of visualising what's currently happening to the descendant class...
You will see that EA shows you which currently available attribute or operation is provided by which ancestor.  In addition, if you enable all the other compartments, you will see the same for Responsibilities, Tags and Constraints.

So, it seems to me, when we link a class to its parent by Generalization, we need to specify for each inherited feature if the descendant is going to change the version of the feature.  EA does that to some extent - it asks you which operations you wish to override when you first make the connection.
What EA (and other tools) don't seem to do is to retain memory of why a particular feature exists in a class.  For example, if I reeffected a feature (overrode it), and I no longer inherit the feature - because I'm now inheriting from another class or no class, shouldn't the tool at least ask the question "Do you still need this reeffected feature?"  Or when you link to a new class and there is a feature with the same name in both the parent (and all ancestors) and the child, it should ask what is to be the relationship between the two?

Finally, what do we mean by Feature?  Well, the UML 2 Superstructure Specification is pretty clear here:
Quote
7.3.20 Feature (from Kernel)
A feature declares a behavioral or structural characteristic of instances of classifiers.
Description:
A feature declares a behavioral or structural characteristic of instances of classifiers. Feature is an abstract metaclass.


So, it seems to me that ALL the behavioural and structural characteristics should be inheritable, this includes:
  • Attributes,
  • Operations,
  • Constraints,
  • Responsibilities,
  • Parameters(in the case of Parameterized Classes)
  • Arguments(in the case of classes bound to Parameterized Classes)
  • Stereotypes
  • The special characteristics: Persistence, IsSpeciaifcation, IsAbstract etc
  • Tagged Values
  • Scenarios


Well, that's what I think...

Discussion welcome.

Paolo





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

thomaskilian

  • Guest
Re: What and How should things get Specialized?
« Reply #1 on: July 11, 2005, 04:12:58 am »
Hi Paolo,
what should I say: you are perfectly right. In order to be able to do all this with EA, there needs to be probably a cleaner understanding of features. EA has its individiual taste of home brew.  Its underlying model is obviously not so CCC (TM) or OOO (TM) -  for comprehensible reasons. I'd raise the questions: is Sparx willing to start a re-design of EA? At what cost? In what time-frame? Are they willing to discuss structural changes in a public forum (probably not, since certain features are EA's USP)? Looking at a short time perspective (and looking through Geoffreys eyes) I'd say NO to all these questions since the product has pretty good reviews. I have no clue how long term perspectives at Sparx are handled. Hopefully better than here...

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: What and How should things get Specialized?
« Reply #2 on: July 11, 2005, 10:02:50 am »
To a certain extent, some of the 'orthogonality' issues would be alleviated by more thorough task-based Help documentation; or even context-sensitive Help.

How do I ...

That presupposes that the Help system knows all about EA :-)

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: What and How should things get Specialized?
« Reply #3 on: July 11, 2005, 02:03:47 pm »
If the requirement is to make an UML CASE tool, they should be willing to discusse if the 'realization' they gave to this requirement is not fullfilled.

I wouldn't go as far as talking about a re-design, but please help us understand what the design decision was behind this inconsistencies where some features get inherited, and some don't. Perhaps, the piece of information we need is what does Sparx consider a 'feature'.

To me EA is great because it is almost an exact implementation of the UML specification, Rose is too 'tailorized' to follow RUP and the rest of the Rational framework, other tools like Vissio are more 'drawing' than UML tools (UML is just the tip of the iceberg for Vissio and they shouldn't worry too much about the whole UML universe).

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: What and How should things get Specialized?
« Reply #4 on: July 11, 2005, 04:48:24 pm »
Quote
So, it seems to me that ALL the behavioural and structural characteristics should be inheritable, this includes:
  • Attributes,
  • Operations,
  • Constraints,
  • Responsibilities,
  • Parameters(in the case of Parameterized Classes)
  • Arguments(in the case of classes bound to Parameterized Classes)
  • Stereotypes
  • The special characteristics: Persistence, IsSpeciaifcation, IsAbstract etc
  • Tagged Values
  • Scenarios


According to UML, attributes (aka Properties) are Features, Operations are Features. Nothing else in your list.

Of course, inheritance will take on specific (trying to think of a word that has no UML meaning but approximates to property, feature, attribute... quality?) qualities of the parent in the child, and some of the items in your list will come into that category. For example, Operation may own an ordered set of Parameters, and that set should be inheritable. I will investigate further...
The Sparx Team
[email protected]

lex_cz

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: What and How should things get Specialized?
« Reply #5 on: July 11, 2005, 04:59:55 pm »
Hi Paolo,
at first I wrote a pretty long answer to you message, but than I found out that I am not that good with EA yet, to argue with you :) So I have following three questions.

What you mean with "Redefining" ?
What you mean with "Undefining" ?
What you mean with "Renaming" ?

Can you write some short examples to those three, say, in C++ ?

I am not sure if you don't want too much from the inheritance in EA. Personally I need EA supporting some "standard" inheritance, where this "standard" is unambiguous.

Regards Martin

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: What and How should things get Specialized?
« Reply #6 on: July 11, 2005, 07:19:37 pm »
Quote
According to UML, attributes (aka Properties) are Features, Operations are Features. Nothing else in your list.
KP,

Can you give the exact reference to support your assertion?  You are correct that Attributes are Features and Operations are Features, but not, in my view from the quoted definitions I gave, that they are the ONLY features.  

In any event, if this were so, why does EA itself (optionally) display "inherited" Constraints, Responsibilities and Tagged Values?  You can't have it both ways...
Quote
Of course, inheritance will take on specific (trying to think of a word that has no UML meaning but approximates to property, feature, attribute... quality?) qualities of the parent in the child, and some of the items in your list will come into that category. For example, Operation may own an ordered set of Parameters, and that set should be inheritable. I will investigate further...
Why not use the UML word?  Characteristics - they chose it for a reason. ;)

BTW by parameters and arguments, in my list I was specifically referring to the Parameters and Arguments of Parameterized classes.  I took it as self evident that parameters and arguments of Operations would be inherited.

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

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: What and How should things get Specialized?
« Reply #7 on: July 11, 2005, 07:45:14 pm »
Quote
Can you give the exact reference to support your assertion?


No, what you need to do is trawl through the Class Descriptions and look at the superclass pointers under the heading "Generalizations". Alternatively, you can search the diagrams in the Abstract Syntax sections.

You will find that Kernel::Feature generalizes Kernel::StructuralFeature, Kernel::BehavioralFeature, InternalStructures::Connector, and nothing else. Now repeat for each of those...
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: What and How should things get Specialized?
« Reply #8 on: July 11, 2005, 09:32:09 pm »
Quote
Hi Paolo,
at first I wrote a pretty long answer to you message, but than I found out that I am not that good with EA yet, to argue with you :) So I have following three questions.

What you mean with "Redefining" ?
What you mean with "Undefining" ?
What you mean with "Renaming" ?
Hi Martin,
I'll take the easier one first...
Renaming:  When you multiply inherit, you may inherit the same named feature from more than one parent.  If the both features are actually instances of the same feature (but by different routes) then the signature should be identical and renaming isn't required.  However, if the signatures are different and the semantics are different, then we can't have two different features with the same name at the same time, therefore we need to rename one.
Given we can (must) rename in the multiple inheritance environment, we can also rename for single inheritance.  For some valid reason, we may want to name an inherited feature differently in the child than in the parent.  Vehicle carries Items, Bus carries Passengers and so on.
Redefining: If the name remains the same, but the signature changes then we are redefining what that name means.  BTW, I'm not formally defining what the term signature means here.  Also, see below on language examples.
Undefining: When abstracting, you often come across a situation where you may have a number of subtypes, most are the same but some don't inherit all of the Features of the Parent.  If you require that the child inherit ALL the features of the parent, you end up creating complex hierarchies to achieve that.  However, if you can say A is a B except if doesn't do q then you can create more compact hierarchies that better express the taxonomic relationships.  The process of restricting a feature from the descendants is known as Undefining.  The outcome is that the child (and its descendants) can't use the feature.

You can get a more precise definition of these terms in: Chapters 14 & 15 of Object-Oriented Software Construction by Bertrand Meyer.
Quote
Can you write some short examples to those three, say, in C++ ?
Well, not really, most languages don't actually support these concepts directly.  C++ is quite problematic here as it allows multiple definitions of the same operation name with different signatures to be considered the the same operation. (I think that's the correct way to describe it - language experts can correct me).
Renaming is NOT allowed in C++ (I believe) - if you inherit the same named feature, you need to rely on C++'s signature recognition.  Otherwise - tough.  Virtual inheritance is a method for telling the compiler that the feature derived by multiple routes is the same feature.
Redefinition in C++ is normal overriding.
Undefining isn't allowed in C++ (as far as I know)
Quote
I am not sure if you don't want too much from the inheritance in EA. Personally I need EA supporting some "standard" inheritance, where this "standard" is unambiguous.

Regards Martin
Well, in my view, EA claims to be a UML tool.  The UML is quite (perhaps not completely) clear on what inheritance means.  EA should conform.  In another post, I'll be suggesting how conformance might be achieved in stages.  The problem for EA is that it is also used for Code round-trip-engineering and as I have said, not all languages support all of the UML concepts (nor even in the same same way sometimes).  My feeling, is that by ensuring they support the UML properly, they get a better handle on how to interface to the physical languages they have to (decide to) support.

HTH,
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: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: What and How should things get Specialized?
« Reply #9 on: July 11, 2005, 09:41:08 pm »
Quote

No, what you need to do is trawl through the Class Descriptions and look at the superclass pointers under the heading "Generalizations". Alternatively, you can search the diagrams in the Abstract Syntax sections.

You will find that Kernel::Feature generalizes Kernel::StructuralFeature, Kernel::BehavioralFeature, InternalStructures::Connector, and nothing else. Now repeat for each of those...
KP,

If you're talking about the Superstructure document, I did check Kernel::StructuralFeature and Kernel::BehavioralFeature before posting.  I didn't find anything that inhibited the list I gave as not being either a structural or behavioural feature.  For example, you could define a Stereotype as a behavioural feature with no parameters.  Or Parameterized Class parameters as Structural Features.

But as I indicated, if your view is correct; then EA has already deviated from the UML standard - in which case complete the job.  If my view is correct, EA has partially implemented the standard, -in which case complete the job.  The outcome is the same.

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: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: What and How should things get Specialized?
« Reply #10 on: July 11, 2005, 10:08:57 pm »
Quote
[size=13][SNIP][/size]I'd raise the question: is Sparx willing to start a re-design of EA? At what cost? In what time-frame? Are they willing to discuss structural changes in a public forum (probably not, since certain features are EA's USP)?[size=13][SNIP][/size]
Thomas,
I'm in agreement with you that, eventually, a redesign will be required.  But I think that's inevitable in order to correctly support UML2 and beyond.  The other tools are finding this also (notably the Lithuanian Tool).
However, in the interim, I think EA already does a very good job in handling inheritance (from a modelling perspective).  From my external view, it would seem a few "tweaks" would go a long way.

I don't know whether I'm teaching Grandmother to suck eggs here, or I being particularly Homer Simpsonish... ;D  But it only really struck me this weekend that from a modelling perspective (as, perhaps, distinct from a code RTE perspective), Inheritance is about rendering to the descendant class that which is available to it from its ancestors.

Reiterating, EA does a very good job in rendering!  As you point out, Thomas, a little bit more OOO TM and a tiny bit more CCC TM would help, but it doesn't really detract from the fact that EA really helps you, the modeller, understand what's happing in the descendant as a result of its parentage.

1) EA already provides a mechanism for optional display of inherited attributes and operations
2) EA also optionally displays inherited constraints, responsibilities and tags.
3) EA also optionally displays parentage (especially for off-digram parents)

4) EA should be able to display inherited Parameterized Class Parameters, and Arguments (it doesn't display local Arguments - but if it did...)
5) Similarly, it should be able to display inherited Stereotypes.
4) and 5) should be able to be accomplished using the existing techniques - remember all these things aren't propagated into the descendants, they are merely rendered on the diagrams.
Similarly, the special features IsSpecification etc can be rendered to indicate if they are merely inheriting the value or whether the value has been overridden in the current class.
The other features, I'm not too fussed about at present.  Indeed, I've not fully thought out whether scenarios are inherited, but my suspicion is they are.  So these others can wait for the redesign.

In my view, the leverage to be gained by implementing 4) and 5) above will repay, what I believe to be, the relatively simple enhancement to existing processes.  And provide yet another USP for EA?

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

thomaskilian

  • Guest
Re: What and How should things get Specialized?
« Reply #11 on: July 12, 2005, 04:36:19 am »
Quote
...And provide yet another USP for EA?...

Well spoken :)

My main concern is, that adding a function here and make a modification there easily clobbers your whole design.  Rather sooner than later your product gets unmaintainable.  I have a recent experience in that :P However, we have to leave that to Sparx and hope they can cope with it.