🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
Derivation expressions
This page was created by Hans.karlsen on 2020-08-25. Last edited by Restore-user on 2026-10-21.

You can derive both attributes and association ends.

When it comes to sub-classes that inherit classes that have anything derived, you may want to override the existing derivations.

You can do this in the Derivation Expressions tool:

Consider this model:

The Green-side subclasses 2,3 match the pink-side subclasses 5,6. It would be good to have a derived association that matches 1 and 4, whatever the subclass is.

  1. Implement the derived link and set the OCL implementation to Class4.nullvalue - it will not be used if your Class1 is abstract.
  2. On class3, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 (valid since Class5 is a Class4)
  3. On class2, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 (valid since Class5 is a Class4)

You have now overridden the dummy default implementation (Class4.nullvalue) to something valid in the context of the subclass.