Aggregation vs reference links
Im working on the same project as described in the post by Christian
Svarrer. We have been working on it in a couple of weeks and haven't figured
out what the difference between an aggregation and a refence link is yet. I
can see that the language acts differently according to the type of link.
What is the diffence and when should you use which link?
Claus Jørgensen
Please sign in to leave a comment.
Claus Jørgensen wrote:
We use trees to store MPS nodes. Every node can have two types of links
agregation and references. We use agregation when we want to make one
node to be child of another and references in another cases.
For example we have expression a = b. The lefthand side and righthand
side nodes are children, i.e. aggregated by assignment node, and are
stored in the same model as its parent (assignment) and within their
parent. The lhs and rhs themselves refer to variable declarations via
reference link, and targets of this link can be stored in different models.
( StatementList )
\agregations
(decl) (decl) ( = )
/ \ / \
\ agregations
int a int b (var) (var)
/
\ /
\
--
|---- |
reference | |
----
reference
Thank you for the reply. I have one more thing. When building a tree
structure using aggregation how do the cardinality work? If you have 1..n at
the source node, what would that look like?
"Konstantin Solomatov" <kostik@jetbrains.com> skrev i en meddelelse
news:dnjt9d$ghh$1@is.intellij.net...
>> Im working on the same project as described in the post by Christian
>> Svarrer. We have been working on it in a couple of weeks and haven't
>> figured out what the difference between an aggregation and a refence link
>> is yet. I can see that the language acts differently according to the
>> type of link. What is the diffence and when should you use which link?
>
>
Claus Jørgensen wrote:
Cardinality means how many nodes you can have in a role. For example
cardinality in variable declaration like int a; type reference has
cardinality is 0..1 to 0..1 this means that there is only one or none in
role of type, i.e. either variable declaration has no type or hasn one
type.
For example in StatementList Cardinlity 0..n to 0..1 means that
StatementList can have many Statemenent for example variable declaration
and if statement.