Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Famix Next-Generation

106 visualizaciones

Publicado el

An introduction to the next-generation of Famix and a tutorial on a concrete example.

Publicado en: Software
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Famix Next-Generation

  1. 1. Famix Next-Generation Julien Deplanque julien.deplanque@inria.fr
  2. 2. Introduction Objectives Understand Famix Next Generation (NG) Get familiar with the DSL Resources https://github.com/SquareBracketAssociates/Booklet- FamixNG (in progress)
  3. 3. How it works Describe your meta-model using the DSL Generator Class Trait Trait Class Class Class
  4. 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.
  5. 5. Take a step back Presentation Slide Slide
  6. 6. Take a step back Slide Slide Uniform Resource Identifier (URI)
  7. 7. A simple meta-model for presentations Uri + uri: String Presentation Slide 0..* 0..* 0..* presentation slides referencedBy referencing
  8. 8. FamixNG-ified meta-model for presentations Uri + uri: String Presentation Slide 0..* 0..* 1 presentation slides UriReference 0..* 1 source outgoingReferences target incomingReferences
  9. 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.
  10. 10. Example presentation := builder newClassNamed: #Presentation. slide := builder newClassNamed: #Slide. uri := builder newClassNamed: #Uri. uriReference := builder newClassNamed: #UriReference.
  11. 11. The DSL - Inheritance Selector Short version Meaning generalization: --|> Inheritance relation Remark: Can be written the other way around (<|- -).
  12. 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.
  13. 13. Example (2) Uri + uri: String Presentation Slide 0..* 0..* 1 presentation slides UriReference 0..* 1 source outgoingReferences target incomingReferences NamedEntity + name: String Association Entity TWithReferences TReference TReferenceable 0..* 1target incomingReferences 0..* 1 outgoingReferences source slide --|> #TWithReferences. uriReference --|> #TReference. uri --|> #TReferenceable
  14. 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.
  15. 15. Example Uri + uri: String Presentation Slide 0..* 0..* 1 presentation slides UriReference 0..* 1 source outgoingReferences target incomingReferences (presentation property: #slides)     <>-* (slide property: #presentation)
  16. 16. The DSL - Properties Selector Meaning #property:type: Creates a property for the class/trait.
  17. 17. Example Uri + uri: String Presentation Slide 0..* 0..* 1 presentation slides UriReference 0..* 1 source outgoingReferences target incomingReferences uri property: #uri type: #String.
  18. 18. Summary (part 1) defineClasses super defineClasses. presentation := builder newClassNamed: #Presentation. slide := builder newClassNamed: #Slide. uri := builder newClassNamed: #Uri. uriReference := builder newClassNamed: #UriReference. defineHierarchy super defineHierarchy. presentation --|> namedEntity. slide --|> namedEntity. slide --|> #TWithReferences. uriReference --|> association. uriReference --|> #TReference. uri --|> entity. uri --|> #TReferenceable.
  19. 19. Summary (part 2) defineRelations super defineRelations. (presentation property: #slides) <>-* (slide property: #presentation) defineProperties super defineProperties. uri property: #uri type: #String
  20. 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. 21. In practice: Step 1 Create a subclass of one of FamixMetamodelGenerator FamixBasicInfrastructureGenerator FamixFileBasedLanguageGenerator
  22. 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. 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. 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. 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'.
  26. 26. Hint: the meta-model Uri + uri: String Presentation Slide 0..* 0..* 1 presentation slides UriReference 0..* 1 source outgoingReferences target incomingReferences
  27. 27. Tutorial time: Fortran https://github.com/juliendelplanque/FamixNGFortran Metacello new repository: 'github://juliendelplanque/FamixNGFortran/src'; baseline: 'FamixNGFortran'; load: 'Tutorial'.
  28. 28. Tutorial time: Fortran

×