The way we handle cardinality is confusing and leads to modelling faults #651
Labels
open for discussion
There is no clear or immediate solution, so discussion is encouraged
subject: model validation
This issue is about validation of Rosetta models, such as the type system
subject: syntax
This issue is about the syntax of Rosetta
subject: UI
This issue is about UI features, such as content assist, auto-completion, etc
By reading an expression, it is often unclear whether it is singular or of multiple cardinality. This vagueness leads to problems in Rosetta models such as the CDM and DRR. Since the problem is deeply ingrained in the language, there are many examples to choose from, but I found the following example from the MAS regulation in DRR especially instructive.
The following rule, misleadingly called
ContractForEvent
, can actually result in multiple trades. This is because the attributeafter
is of multi cardinality (something which isn't clear when reading this), andafter -> trade
will implicitly map everyTradeState
to its correspondingTrade
.This results in more confusion down the line. For example, the following rule actually results in multiple booleans rather than a single one.
The actual intention for the rule is probably to determine whether or not a single
Trade
represents a "interest rate payout", i.e.,Our current approach of designing the DSL was to try and hide technicalities of cardinality from modellers. However, as the example above illustrates, this can easily lead to a false sense of understanding what's going on, leading to more confusion and faults in the model in the long term.
Suggestions on improvements
I can think of five kinds of changes that will improve transparency and reduce modelling bugs. For each of them, I give a suggestion on how to fill it in, although further analysis is required to verify the best approach.
*
, or cardinality info on hover to indicate when a modeller is working with attributes/expressions of multi cardinality.->
on expressions of multi-cardinality. Modellers should useextract
instead.flatten
ing (then flatten
) right after anextract
expressions that would result in a list of lists. Alternatively, consider joiningextract
andflatten
together into a single operation (e.g.,flat-extract
).variable
versus[variable]
- both have a cardinality of(1..1)
), or whether we should keep this conversion implicit.The text was updated successfully, but these errors were encountered: