Model-based Software Engineering (02341, Spring 2017)
I. Introduction
1. Motivation What is software engineering? What is software? software = program software engineering = programming 3
Program vs. Software is much more than Software >> Program Software Engineering >>> Programming is much much more than 4
Programming vs. SE Software Software Engineer Software Engineering Program Programmer Programming 5
Software Die Menge aller Programme, Prozeduren und Objekte, zusammen mit den zugehörigen Daten und der Dokumentation, die für eine lauffähige Anwendung nötig oder wünschenswert sind. [frei nach Informatik DUDEN und Hesse] 6
Software The sum of all programs, procedures and objects along with the associated data and documentation, which are necessary (or at least desirable) for running an application on a computer system. 7
2. Models in SE and a glimpse of how software can be developed by using models without doing any programming at all. 8
Modelling 9
Idea for some Software 10
Example of a Petri net request 1 request 2 critical 1 critical 2 semaphor idle 1 idle 2 11
Stages Examples Taxonomy (done on blackboard) Glossary Model (developed on blackboard) 12
Models (Meta Models) PetriNet object * Object context Arc inv: ( self.source.ocliskindof(place) and self.target.ocliskindof(transition) ) or ( self.source.ocliskindof(transition) and self.target.ocliskindof(place) ) Petri net model Node 1 source 1 target Arc Transition Place Model Meta model for Petri for nets Petri nets token * Token 13
Don t think models as Java PetriNet * Object context Arc inv: ( self.source.ocliskindof(place) and self.target.ocliskindof(transition) ) or ( self.source.ocliskindof(transition) and self.target.ocliskindof(place) ) Petri net model Node 1 source 1 target Arc Transition Place * Token 14
Domain model A domain model makes the concepts of a domain explicit It makes the concepts and the relations among them precise As software engineers, we used UML (class diagrams) as a language for formulating a domain model Process Examples Talk to experts Taxonomy / Glossary Create the model 15
Domain model PetriNet * Object context Arc inv: ( self.source.ocliskindof(place) and self.target.ocliskindof(transition) ) or ( self.source.ocliskindof(transition) and self.target.ocliskindof(place) ) Petri net model Node 1 source 1 target Arc Transition Place * Token 16
Syntax for instances :Petrinet graphical / concrete syntax :Transition target source :Arc target :Place source :Arc abstract syntax (as an UML object diagram) :Arc :Token :Place source target :Arc source target :Transition 17
Overview PetriNet meta model build-time * Object Node 1 source 1 target Arc is an instance of Transition Place * Token :Petrinet :Transition source :Arc target :Place target source model runtime :Arc :Arc :Token :Place source target :Arc source target :Transition 18
Benefits of Modelling Better understanding Mapping of instances to XML syntax (XMI) Automatic code generation API for creating, deleting and modifying model Methods for loading and saving models (in XMI) Standard mechanisms for keeping track of changes (observers) 19
PetriNet * Object Node 1 source 1 target Arc Transition Place * Token :Petrinet :Transition source :Arc target :Place target source :Arc :Arc :Token :Place source target :Arc source target :Transition 20
Answers: Program an editor Standard technology for mapping abstract to concrete syntax: EMF / GMF / 21
GMF/Sirius PetriNet Transition * Place Object Arc Token Node 1 source 1 target Arc Transition Place * Token generate an editor :Petrinet :Transition source :Arc target :Place target source :Arc :Arc :Token :Place source target :Arc source target :Transition 22
Benefits of Modelling (cntd.) Better Understanding Mapping of instances to XML syntax (XMI) Automatic Code Generation API for creating, deleting and modifying model Methods for loading and saving models (in XMI) Standard mechanisms for keeping track of changes (observers) Editors and GUIs 23
Idea for some Software 24
Today Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginname package PetriNets.impl; Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr Bundle-Version: 1.0.0.qualifier public class PetriNetImpl extends EObjectImpl implements PetriNet { Bundle-ClassPath: <plugin>. protected EList<PetriNets.Object> object; Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr Bundle-Vendor: %providername <extension point="org.eclipse.emf.ecore.generated_pa protected PetriNetImpl() { Bundle-Localization: <package plugin super(); Export-Package: PetriNets.diagram.edit.parts, uri = "PetriNets" } PetriNets.diagram.part, class = "PetriNets.PetriNetsPackage" PetriNets.diagram.providers genmodel = "model/petrinet.genmodel" /> protected EClass estaticclass() { Require-Bundle: org.eclipse.core.runtime, </extension> return PetriNetsPackage.Literals.PETRI_NET; org.eclipse.core.resources, } org.eclipse.core.expressions, </plugin> org.eclipse.jface, public EList<PetriNets.Object> getobject() { org.eclipse.ui.ide, if (object == null) { org.eclipse.ui.views, object = new EObjectContainmentEList<PetriNets.Object>(Petri org.eclipse.ui.navigator, } org.eclipse.ui.navigator.resources, return object; org.eclipse.emf.ecore, } org.eclipse.emf.ecore.xmi, org.eclipse.emf.edit.ui, public NotificationChain einverseremove(internaleobject otherend, int org.eclipse.gmf.runtime.emf.core, switch (featureid) { org.eclipse.gmf.runtime.emf.commands.core, case PetriNetsPackage.PETRI_NET OBJECT: org.eclipse.gmf.runtime.emf.ui.properties, return ((InternalEList<?>)getObject()).basicRemove(otherEn org.eclipse.gmf.runtime.diagram.ui, } org.eclipse.gmf.runtime.diagram.ui.properties, return super.einverseremove(otherend, featureid, msgs); org.eclipse.gmf.runtime.diagram.ui.providers, } org.eclipse.gmf.runtime.diagram.ui.providers.ide, org.eclipse.gmf.runtime.diagram.ui.render, public Object eget(int featureid, boolean resolve, boolean coretype) { org.eclipse.gmf.runtime.diagram.ui.resources.ed switch (featureid) { org.eclipse.gmf.runtime.diagram.ui.resources.e case PetriNetsPackage.PETRI_NET OBJECT: APetriNetEditorIn15Minutes;visibility:=reexpor return getobject(); } return super.eget(featureid, resolve, coretype); 25
Vision 26
Vision PetriNet * Object 1 source Node 1 target Transition Place Arc * Token Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginname package PetriNets.impl; Bundle-SymbolicName: APetriNetEditorIn15Minutes.diagr Bundle-Version: 1.0.0.qualifier public class PetriNetImpl extends EObjectImpl implements PetriNet { Bundle-ClassPath:. protected EList<PetriNets.Object> object; Bundle-Activator: PetriNets.diagram.part.PetriNetDiagr Bundle-Vendor: %providername protected PetriNetImpl() { Bundle-Localization: plugin super(); Export-Package: PetriNets.diagram.edit.parts, } PetriNets.diagram.part, PetriNets.diagram.providers protected EClass estaticclass() { Require-Bundle: org.eclipse.core.runtime, return PetriNetsPackage.Literals.PETRI_NET; org.eclipse.core.resources, } org.eclipse.core.expressions, org.eclipse.jface, public EList<PetriNets.Object> getobject() { org.eclipse.ui.ide, if (object == null) { org.eclipse.ui.views, object = new EObjectContainmentEList<PetriNets.Object>(Petri org.eclipse.ui.navigator, } org.eclipse.ui.navigator.resources, return object; org.eclipse.emf.ecore, } org.eclipse.emf.ecore.xmi, org.eclipse.emf.edit.ui, public NotificationChain einverseremove(internaleobject otherend, int org.eclipse.gmf.runtime.emf.core, switch (featureid) { org.eclipse.gmf.runtime.emf.commands.core, case PetriNetsPackage.PETRI_NET OBJECT: org.eclipse.gmf.runtime.emf.ui.properties, return ((InternalEList<?>)getObject()).basicRemove(otherEn org.eclipse.gmf.runtime.diagram.ui, } org.eclipse.gmf.runtime.diagram.ui.properties, return super.einverseremove(otherend, featureid, msgs); org.eclipse.gmf.runtime.diagram.ui.providers, } org.eclipse.gmf.runtime.diagram.ui.providers.ide, org.eclipse.gmf.runtime.diagram.ui.render, public Object eget(int featureid, boolean resolve, boolean coretype) { org.eclipse.gmf.runtime.diagram.ui.resources.ed switch (featureid) { org.eclipse.gmf.runtime.diagram.ui.resources.e case PetriNetsPackage.PETRI_NET OBJECT: APetriNetEditorIn15Minutes;visibility:=reexpor return getobject(); } return super.eget(featureid, resolve, coretype); Analysis Design Implementation Coding 27
Buzzwords Model Driven Architecture (MDA ) OMG TM software development approach for separating business logic from platform specific details using models automatic generators (for code and other models) Model-based Software Engineering (MBSE) General term for making better use of models for easing the software development Ultimately: Getting rid of programming resp. technical artefacts. 28
Buzzwords DSL (Domain Specific Language): Make it easy to develop a language for some domain (in our example Petri nets) along with editors (graphical or textual) MBSE technologies can be used for developing DSLs by using domain models (meta-models) More on the use of the term meta and meta-model later in this course 29
Theses We will always have programming and programmers! We should always teach programming! But, software engineers should be trained in their engineering and modelling skills! And this is where they should be at their best! Most of the rest can be automated! Eventually, programming will be for software engineers as assembler is today for programmers. 30
3. Modelling with a Purpose Anologies: Models as floor plans (see earlier slides) Architects and construction engineers use quite different kind of plans driven by the puprose They even use models (miniatures) Models as maps Understand the world ( domain) PetriNet * Object Node 1 source Arc 1 target Find your way round in the software Transition Place Token * 31
Maps 32
Maps Different level of abstraction and detail Different focus Different aspects Different purpose 33
Software vs Programming For programs (small software) models are often not needed, and making them might be a waste of time. For software they are essential for building something which works out and the different pieces fit to each other 34
Discussion Two models: Which is better? Always ask first: Better for what? PetriNet * Object Node 1 source 1 target Arc Transition Place * Token 35
Course: today Lecture Introduction and Motivation Organization Organisation of this course Project More details on the project in week 4! Tutorial Tutorial 1: Getting started with EMF (Petrinet example) Overview of task and steps DO IT 36