Week 5: Graphical DSMLs
Goals for today
Today we will look at graphical DSMLs
Copyright By PowCoder代写 加微信 powcoder
– Understand how to develop DSMLs starting from domain analysis – Understand what graphical DSMLs are
– Understand how to build graphical DSMLs with Eclipse Sirius
A different way to develop DSMLs
Reflection: What have we done so far?
So far, we have started directly from the concrete syntax of our DSML
– Can directly show something to the domain expert and end user – Have a working prototype very quickly
– Can be very difficult to ensure the right concepts are in the language
– Concrete syntax can be difficult to develop when we don’t yet know what the language is about
14/02/2020 (c) King’s College London 4
An Alternative: Domain Modelling
Goal: Understand the terms of the user’s domain
– Key concepts and relations between them
– Requirement descriptions – User interviews
– Literature
– E.g., domain standards or textbooks
14/02/2020 (c) King’s College London 5
An Example Domain Model
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020 (c) King’s College London 6
An Example Domain Model
Boxes for Domain Concepts
CustomerAccount Order PaymentDetails
Customer Basket
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020
(c) King’s College London
An Example Domain Model
Customer Basket
CustomerAccount
PaymentDetails
Arrow Line for Generalisation
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
Furniture Item
14/02/2020
(c) King’s College London
An Example Domain Model
Associations for Relationships b/w Domain Concepts
maintains 1
contains *
Customer Basket
CustomerAccount Order PaymentDetails
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020
(c) King’s College London
An Example Domain Model
Associations for Relationships b/w Domain Concepts
maintains 1
contains *
Customer 1 CustomerAccount has
Order PaymentDetails
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020
(c) King’s College London
An Example Domain Model
maintains 1
Catalogue browses 1
contains *
Customer 1 CustomerAccount has
Order PaymentDetails
14/02/2020
(c) King’s College London
Associations for Relationships b/w Domain Concepts
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
An Example Domain Model
Associations for Relationships b/w Domain Concepts
maintains 1
Catalogue browses 1
contains *
Customer 1 CustomerAccount has
has history of *
PaymentDetails
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020
(c) King’s College London
An Example Domain Model
Shop Catalogue browses
contains *
Product concerns
maintains 1
Customer 1 CustomerAccount has
has history of *
PaymentDetails
contains *
ItemOrder contains 1*
Furniture Item
’s tutorial on domain modelling:
http://www.youtube.com/view_play_list?p=EE77921A75E846EB
14/02/2020
(c) King’s College London
What’s a Domain Concept?
Any term that a stakeholder uses
– Whether or not you think it will be needed as a data type
Anything you need to be able to distinguish
– Library Item and Library Item Copy: can distinguish different copies of “The Gruffalo” when needed
– Derive from descriptions of what behaviours are needed
Use your own common sense in addition to direct stakeholder input
– BUT: Check with stakeholder and get confirmation!
14/02/2020 (c) King’s College London 7
From domain models to languages
Domain models look suspiciously like metamodels
But, they are not the same thing:
– Now need to reason about what needs expressing in DSML and what doesn’t – Two things to consider:
1. Between different example problems in the same domain, what changes and what remains the same?
– DSML only needs to capture things that change
2. What do we need to describe vs what needs to happen? – DSML only needs to capture descriptions
– If we can infer it from other information, we don’t need to describe it
– Metamodel is about structure of the descriptions not structure of the domain – E.g., rules for giving discounts vs implementation of discounting process
– Notion of a rule doesn’t exist in the domain, but concrete examples of such rules would show up in a domain model
14/02/2020 (c) King’s College London 8
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
14/02/2020 (c) King’s College London 9
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
1. Create a new Project
14/02/2020 (c) King’s College London 9
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
1. Create a new Project
2. Give it a sensible name, then click Finish
14/02/2020 (c) King’s College London 9
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
1. Create a new Project
2. Give it a sensible name, then click Finish
3. Use the graphical editor to define the metamodel
14/02/2020 (c) King’s College London 9
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
1. Create a new Project
2. Give it a sensible name, then click Finish
3. Use the graphical editor to define the metamodel
4. Generate implementation code using the context
14/02/2020 (c) King’s College London 9
Defining a metamodel with Eclipse EMF
To define a new metamodel in Eclipse:
1. Create a new Project
2. Give it a sensible name, then click Finish
3. Use the graphical editor to define the metamodel
4. Generate implementation code using the context
14/02/2020 (c) King’s College London 9
In your pairs
– Create the flowchart metamodel from the previous slides – Generate implementation classes and inspect them
You have 10 minutes
14/02/2020 (c) King’s College London 10
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse 2. Create a new project
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’ 4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
5. Step through the wizard to create the new file
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
5. Step through the wizard to create the new file
6. Then choose the top-level model element (Flow Chart)
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
5. Step through the wizard to create the new file
6. Then choose the top-level model element (Flow Chart)
7. The model is opened in the default tree editor
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
5. Step through the wizard to create the new file
6. Then choose the top-level model element (Flow Chart)
7. The model is opened in the default tree editor
8. Use context menu to add nodes
14/02/2020 (c) King’s College London 15
Editing models without a concrete syntax
Already with only the abstract syntax built, we can create and edit models
– Not very comfortable or user friendly
– But hugely helpful when creating and debugging new languages
Uses the default tree editor
1. Start the runtime Eclipse
2. Create a new project
3. In the project right-click and select ‘New/Other…’
4. Then choose the ‘Flowcharts Model’ wizard
1. Note this is a default wizard, you can later customise this for your language
5. Step through the wizard to create the new file
6. Then choose the top-level model element (Flow Chart)
7. The model is opened in the default tree editor
8. Use context menu to add nodes
9. Use properties view to edit fields
14/02/2020 (c) King’s College London 15
In your pairs
– Create a model from your flowchart abstract syntax – Add some steps, forks, etc.
You have 5 minutes
14/02/2020 (c) King’s College London 16
Graphical DSMLs
Reminder: Elements of modelling languages
Defines meaning of
– Defines what a model means
Abstract syntax
– Language concepts – Class, Attribute, Cell, CellState – Links between these concepts
– Class has Attributes
– Cell has CellStates
– Transitions have source and target CellStates
Represents to user
– How computer interacts with models
14/02/2020 (c) King’s College London
Indirectly defines meaning of
– Graphical, textual, tabular, …
– How humans interact with models
Concrete syntax Concrete syntax
– Graphical, textual, tabular, …
– How humans interact with models
Reminder: Elements of modelling languages
Defines meaning of
– Defines what a model means
Abstract syntax
– Language concepts – Class, Attribute, Cell, CellState – Links between these concepts
– Class has Attributes
– Cell has CellStates
– Transitions have source and target CellStates
Represents to user
– How computer interacts with models
Concrete syntax Concrete syntax
14/02/2020 (c) King’s College London
Indirectly defines meaning of
– Graphical, textual, tabular, …
– Graphical, textual, tabular, …
– How humans interact with models
– How humans interact with models
Principles of graphical syntax: Elements of diagrams
Graphical syntax means diagrams
– Typically graphs of connected nodes and edges – Positioned on a canvas
– Nodes can have
– Different shapes
– Sometimes, nodes can contain other nodes
– Are lines
– Connect two nodes
– Rarely, edges connect more than two nodes or connect edges – Can have end decorations (arrows, …)
– Can have labels in various positions
14/02/2020 (c) King’s College London 21
Principles of graphical syntax: Parsing vs projection
Textual languages are based on parsing
step myStep next mySecondStep step mySecondStep
14/02/2020 (c) King’s College London 22
Principles of graphical syntax: Parsing vs projection
Textual languages are based on parsing
step myStep next mySecondStep step mySecondStep
:Flow Chart
myStep:Step
name = “myStep” name = “mySecondStep”
mySecondStep:Step
14/02/2020 (c) King’s College London
Principles of graphical syntax: Parsing vs projection
Textual languages are based on parsing
Graphical languages are (mostly) based on projection:
– Produce diagram from abstract syntax
– User always changes abstract syntax, never diagram – Diagram is refreshed when abstract syntax
:Flow Chart
myStep:Step
name = “myStep” name = “mySecondStep”
mySecondStep:Step
mySecondStep
14/02/2020 (c) King’s College London
Sirius is a DSML for describing graphical concrete syntax for your language
– Declarative definition of graphical concrete syntax
– Interpreted, so changes are automatically reflected
– Diagrams are described in .odesign files
– Tree editor for capturing all the relevant information – Sirius also supports tabular concrete syntax
Sirius is an Eclipse plugin
– Works for any language developed using EMF and Ecore – For example, our FlowCharts language
14/02/2020 (c) King’s College London 23
Creating a Sirius specification
Diagram specifications are easiest developed in the runtime Eclipse
– Where your abstract syntax is already installed
– Remember, Sirius is interpreted, so will pick up the specification immediately
14/02/2020 (c) King’s College London 24
Creating a Sirius specification
Diagram specifications are easiest developed in the runtime Eclipse
– Where your abstract syntax is already installed
– Remember, Sirius is interpreted, so will pick up the specification immediately
1. Create a new Viewpoint Specification project
14/02/2020 (c) King’s College London 24
Creating a Sirius specification
Diagram specifications are easiest developed in the runtime Eclipse
– Where your abstract syntax is already installed
– Remember, Sirius is interpreted, so will pick up the specification immediately
1. Create a new Viewpoint Specification project
2. This opens the Sirius specification model in the editor 3. Now we’re ready to create diagram specifications
14/02/2020 (c) King’s College London 24
Sirius: Structure of a specification
Sirius distinguishes two levels of syntax specification:
1. Viewpoints
2. Representations
14/02/2020 (c) King’s College London 25
Sirius: Structure of a specification
Sirius distinguishes two levels of syntax specification:
1. Viewpoints
– A collection of diagram / table types that help with a particular modelling task – Can have multiple viewpoints in one Sirius specification
2. Representations
14/02/2020 (c) King’s College London 25
Sirius: Structure of a specification
Sirius distinguishes two levels of syntax specification:
1. Viewpoints
– A collection of diagram / table types that help with a particular modelling task – Can have multiple viewpoints in one Sirius specification
2. Representations
– Actual diagram / table type specifications
– Can have multiple, inter-linked representations in the same viewpoint
14/02/2020 (c) King’s College London 25
Sirius: Editing your specification
Editing a specification is a combination of
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
First let’s set up the basic view point information
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
First let’s set up the basic view point information
– Select the ViewPoint in the tree and go to the properties view
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
First let’s set up the basic view point information
– Select the ViewPoint in the tree and go to the properties view
– Enter a meaningful viewpoint name and associate it with .flow files
– Remember you can always hover over the (?) icon to access documentation
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
First let’s set up the basic view point information
– Select the ViewPoint in the tree and go to the properties view
– Enter a meaningful viewpoint name and associate it with .flow files
– Remember you can always hover over the (?) icon to access documentation – Add a new Diagram Description to your view point
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
– Making changes to the tree and – Changing properties
First let’s set up the basic view point information
– Select the ViewPoint in the tree and go to the properties view
– Enter a meaningful viewpoint name and associate it with .flow files
– Remember you can always hover over the (?) icon to access documentation
– Add a new Diagram Description to your view point
– Set the ID and Domain Class (use Ctrl+Shift in a green or yellow field to getcode completion)
– Note you need not edit the blue field; it is filled automatically
14/02/2020 (c) King’s College London 26
Sirius: Editing your specification
Editing a specification is a combination of
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com