eclipse-uml2 / uml2

An EMF-based implementation of the UML 2.x metamodel for the Eclipse platform.
Eclipse Public License 2.0
5 stars 4 forks source link

Polymorphic properties are not supported #109

Open eclipse-uml2-bot opened 1 week ago

eclipse-uml2-bot commented 1 week ago

| --- | --- | | Bugzilla Link | 571862 | | Status | NEW | | Importance | P3 normal | | Reported | Mar 11, 2021 02:25 EDT | | Modified | Mar 11, 2021 02:27 EDT | | See also | 571612 | | Reporter | Ed Willink |

Description

In Bug 571612 a repro has a redefined stereotype property with a distinct initializer, which the genmodelling ignores.

I resolved the OCL bug as INVALID

a) because it involved no OCL functionality

b) because I have often observed that UML does not support polymorphic properties

Wrong. UML does not support polymorphic operations either. Rather UML is an assembly language with various scaffolding capabilities that can be used to fabricate common idioms.

Thus plausible (and also very dubious) operation override hierarchies can be configuted by redefinitions.

Therefore plausible property redefinitions can also construct override hierarchies. And with an Ecore2Java implementation using getXXX operations as the implementation polymorphism should be as easy to implement as operations.

In the context of the repro:

BaseStereoTypeImpl (not a problem) has:

protected static final String SOME_PROPERTY_EDEFAULT = "base default value";

protected String someProperty = SOME_PROPERTY_EDEFAULT;

But DerivedStereotypeImpl has no relevant code. Surely it should be:

protected static final String DERIVED_STEREOTYPE_SOME_PROPERTY_EDEFAULT = "derived default value";

protected DerivedStereotypeImpl() {\
    super();\
        someProperty = DERIVED_STEREOTYPE_SOME_PROPERTY_EDEFAULT ;\
    }

Workaround: if OCL-bodied OpaqueExpressions rather than LiteralStrings are used as the initializer, the normal get/set polymorphism should kick in.