moosetechnology / Famix

An abstract representation of source code. Famix is generic and can describe applications in multiple programming languages.
MIT License
13 stars 23 forks source link

syntactic sugar for association description in generator #117

Open NicolasAnquetil opened 4 years ago

NicolasAnquetil commented 4 years ago

just like #apply:on:oppositeTraits:on: for "reciprocal traits", there could be a generator method to simplify creating association between two classes

NicolasAnquetil commented 4 years ago

see moosetechnology/Moose#2070

NicolasAnquetil commented 4 years ago

may be a method like: #applyAssociation:fromSide:toSide: or withFrom:withTo: or fromRole:toRole: ...

NicolasAnquetil commented 4 years ago

Currently to create an association such as Invocation, we must:

Things happen in two methods (#defineClasses and #defineHierarchy), often lines are separated because the classes have other properties/inheritances, so the information is scattered which does not make clear the creation of a relationship.

Improvement initially wished was to create classes as usual and define the relationship (i.e. uses of traits) in #defineRelations:

apply: TInvocation on: Invok-class withFrom: Invoker-class withTo: Invoked-class

But we don't have identification of from/to slots in TInvocation so we cannot compute the trait needed by the from/to sides.

NicolasAnquetil commented 4 years ago

Two possible solutions:

applyAssociation: TInvocation on: Invok-class fromSlot: #sender on: Invoker-class toSlot: #candidates on: Invoked-class

(sender is the from slot in TInvocation and candidates is the to slot)

applyAssociation: Invok-class fromSlot: #sender on: Invoker-class toSlot: #candidates on: Invoked-class