3. How it works
Describe your meta-model using the DSL
Generator
Class
Trait
Trait
Class
Class
Class
4. Differences with previous version
(Old) Famix Famix NG
Implement MM as Pharo classes. Implement MM using the
DSL
Huge usage of inheritance. Huge usage of traits.
Single MM. Multiple MM.
Verifications on the MM once
created.
Verifications on the MM
from its specification
written using the DSL.
9. The DSL - Entities
Selector Meaning
#newClassNamed:comment: Creates a new class for the MM
#newTraitNamed:comment: Creates a new stateful trait for the MM
Question: How to choose?
Classes must be used for entities that will be instantiated.
Traits can not be instantiated.
Can only inherit from one class.
Can “inherit” from multiple traits.
11. The DSL - Inheritance
Selector Short version Meaning
generalization: --|> Inheritance relation
Remark: Can be written the other way around (<|- -).
12. Example (1)
Uri
+ uri: String
Presentation
Slide
0..*
0..*
1
presentation
slides
UriReference
0..*
1
source
outgoingReferences
target
incomingReferences
NamedEntity
+ name: String
Association
Entity
presentation --|> namedEntity.
slide --|> namedEntity. uriReference --|> association.
uri --|> entity.
14. The DSL - Relations
Selector Short version Meaning
oneBelongsTo: -<> Composition with 1 child
manyBelongTo: *-<> Composition with 0..* children
containsOne: <>- Composition with 1 child
containsMany: <>-* Composition with 0..* children
oneToOne: - Association 0..1 to 0..1
oneToMany: -* Association 0..1 to 0..*
manyToOne: *- Association 0..* to 0..1
manyToMany: *-* Association 0..* to 0..*
Remark: As in the old Famix, Famix NG relations ensure
that if one side of the relation is modified, the other side
is updated accordingly.
19. Summary (part 2)
defineRelations
super defineRelations.
(presentation property: #slides)
<>-* (slide property: #presentation)
defineProperties
super defineProperties.
uri property: #uri type: #String
20. Basic infrastructure traits catalog
Famix-Traits package provides a set of traits implementing
generic concepts reusable accross meta-models.
FamixTReference, FamixTReferenceable and
FamixTWithReferences
FamixTAccess, FamixTAccessible and
FamixTWithAccesses
FamixTClass and FamixTWithClasses
. . .
To use one of these traits in your meta-model builder, reference
it via a symbol (without Famix prefix).
"Here you make Uri class use FamixTReferenceable"
uri --|> #TReferenceable.
21. In practice: Step 1
Create a subclass of one of
FamixMetamodelGenerator
FamixBasicInfrastructureGenerator
FamixFileBasedLanguageGenerator
22. In practice: Step 2
Implement class-side methods #packageName (name of the package
in which the MM will be generated) and prefix (prefix for your
generated classes)
23. In practice: Step 3
Override the following instance-side methods depending on what
part of the MM you describe:
#defineClasses for classes definitions
#defineHierarchy for classes inheritance definitions
#defineRelations for classes relations definitions
#defineProperties to define classes properties
#defineTraits for traits definitions
24. In practice (summary)
1. Create a subclass of one of
FamixMetamodelGenerator
FamixBasicInfrastructureGenerator
FamixFileBasedLanguageGenerator
2. Implement class-side methods #packageName (name of the
package in which the MM will be generated) and prefix
(prefix for your generated classes)
3. Override the following instance-side methods depending on
what part of the MM you describe:
#defineClasses for classes definitions
#defineHierarchy for classes inheritance definitions
#defineRelations for classes relations definitions
#defineProperties to define classes properties
#defineTraits for traits definitions
25. Tutorial time: Presentation
Load a fresh Moose 7 image from the CI and implement the
previous meta-model.
Metacello new
repository:
'github://juliendelplanque/FamixNG-Slides/src';
baseline: 'FamixNGSlides';
load: 'Tutorial'.