IT Vertiefung Model Driven Software Development MDSD Concepts Metamodeling, MOF, Ecore MDSD Process Model Driven Generation OMG Model Driven Architecture Edin Arnautovic Wolfgang Radinger MDSD Concepts Warum modellieren wir? Modelle sind notwendig um Informationen verständlicher darzustellen um essentielle Systemaspekte aufzuzeigen zur Kommunikation (Projektmitglieder, Kunde) um komplexe Systeme darstellen zu können 1
Models in Traditional Engineering As old as engineering Traditional means of reducing engineering risk What Engineers Do Before they build the real thing... they first build models and then learn from them from Brian Seltic from Brian Seltic Models Engineering model A reduced representation of some system that is easier to understand than the actual system How Models are Used To detect errors and omissions and to determine key tradeoffs in complex designs before committing full resources to realization Through (formal) analysis and experimentation Models are the new code When the system evolves or a problem occurs, modify a model, or a mapping, not the code! Assembly Code Assembler High Level Language Source Code Source Code Compiler Executable Models Model Compiler Investigate and compare alternative solutions Minimize engineering risk To communicate with stakeholders Clients, users, implementers, testers, documenters, etc. To drive implementation Computer Technology 7/99 Machine Code 1960 s None Assembly Code 1980 s Hardware Platform Source Code 2000 s Software Platform 2
What is MDSD? MDSD = Model Driven Software Development different than model based Model based vs. model driven Models are first class objects Based around domain driven metamodeling It is also: development of infrastructure to develop software (software factories) Computer Technology 10/99 Reasons for using MDSD You want to provide a way for your domain experts to formally specify their knowledge, and to provide a way for your technology people to define how this is implemented (using model transformations). You might want to provide different implementations (i.e. more concrete models) for the same model, perhaps because you want to run it on different platforms (.NET, Java, CORBA). You may want to capture knowledge about the domain, the technology, and their mapping in a clear, uncluttered format. Advantages of MDSD Better integration of domain experts Faster software changes Validation of software under construction Better realization of the software architecture Enhanced portability to other platforms In general, you don t want to bother with implementation details when specifying your functionality. MDSD results in a fan out, i.e. one set of models can be the source for transformations to several targets. More efficient for product line development Reuse of generators and transformation rules Another reason for using MDSD: You are working in the context of product lines and software system families and need to develop domain specific assets. Computer Technology 2 0 0 4 M a rk u s V ö l t e r -11-/99 3
Disadvantages of MDSD Higher overhead for one of a kind system Concepts Models expressing the application functionality based on domain specific languages Domain specific languages, usually expressed by metamodels Platforms contains common middleware (e.g. CORBA, J2EE, or.net) and domain specific frameworks Transformations to map models to platforms How MDSD works Developer develops model(s) based on certain metamodel(s), expressed using a DSL. Using code generation templates, the model is transformed to executable code. Alternative: Interpretation Optionally, the generated code is merged with manually written code. One or more model to model transformation steps may precede code generation. Model Model Model Transformer Model Transformer Metamodel Tranformation Rules Metamodel Code Generation Templates optional, can be repeated Domain Driven Development Domain Driven Development is about making software development more domain related as opposed to computing related. It is also about making software development in a certain domain more efficient. Domain Concepts mental work of developers Software Technology Concepts Domain Concepts Software Technology Concepts Manually Generated Code Written Code optional 2 0 0 4 M a rk u s V ö l t e r Computer Technology -15-/99 2 0 0 4 M a rk u s V ö l t e r Computer Technology -16-/99 4
What is a Domain A definition could be: A domain is a bounded area of knowledge or interest. Examples (from the world of Software) include: ebanking Embedded Software Web Based ebusiness Applications Control Software for 4 Cylinder Diesel Engines Astronomical Image Processing Software Domains can have varios scopes as well as various flavours. Kinds of Domains In the context of software development it is also useful to distinguish (at least) two kinds of domains: Functional Domains represent the business/professional issues; Banking Human resource management Insurance Engine Controllers Astronomical Telescope Control Technical Domains adress key technical issues for software development Distribution, Failover and Load Balancin Persistence and Transactions GUI Design 2 0 0 4 M a rk u s V ö l t e r Computer Technology -17-/99 Institute of Concurreny and Realtime 2 0 0 4 M a rk u s V ö l t e r Computer Technology -18-/99 Domain Specific Language Defines the semantic of the model The notation (concrete syntax) of the DSL can be textual or graphical More important: The DSL s abstract syntax, better known as metamodel Metamodel defines the model elements for domain modeling Metamodeling / Meta Object Facility The DSL s semantics are used to transform the DSL to generalpurpose languages 5
Klasse vs. Objekte Klassen stellen Konzepte dar. Bei OOP werden sie in einer OO Programmiersprache implementiert Objekte dieser Klasse existieren zur Ausführungszeit, um das Verhalten und Wissen des Systems bereitzustellen. Klasse Objekt Auto Kennzeichen :Auto W 12345 A :Auto W 2222 XY :Auto W 1111 AB :Auto S 1234 XY Objektdiagramme Statische Objektdiagramme sind manchmal hilfreich Bei der Erläuterung des Klassendiagramms Bei Schwierigkeiten mit der Klassifikation Zur Untersuchung der Multiplizität Zur Darstellung von Vorher und Nachher Zuständen leg_1:leg Abflugort = VIE Zielort =FRA myflug:flug Abflugort = VIE Zielort =LAX leg_2:leg Abflugort = FRA Zielort =LAX Aggregation Die Aggregation bestimmt Ganzes Teil Beziehungen. Beispiel: Aggregation Besitzverhältnis Die Klasse die das Ganze darstellt besitzt die Klasse die die Teile modelliert, und steuert den Zugriff. Lebensspanne Das Ganze erstellt und löscht die Teile. Zugriffsmöglichkeiten Auf die Teile wird über das Ganze zugegriffen. Weiterreichung Einige Operationen auf der Ebene des Ganzen bewirken die gleichen Operationen bei den Teilen. Mahlzeit {or} 1 1 1 1 Suppe Salat Hauptgericht Dessert 6
Multiplizitäten Bereiche [min max] z.b. [1..10] Komposition Die Komposition ist eine starke Aggregation. * beliebig z.b. [0..*] Drückt eine physikalische Inklusion der Teile im Ganzen aus. genau 1: 1 Teile und Ganzen bilden eine Einheit 0: * oder 0..* 0 1: 0..1 fixe Anzahl (z.b. 3): 3 Kaffeetisch 1 Bereich (z.b. 3): 3..* Bereich (z.b. 3-6): 3..6 Aufzählung : 3,6,7,8,9 oder 3, 6..9 1 4 Tischplatte Tischbein Folie Hitz & Kappel, UML @ Work Metamodel Meta : means about Metamodel: describes the possible structure of models conforming to the metamodel Metamodeling 1 Domain Model Metamodel Real-world elements model elements metamodel elements describes describes Computer Technology 28/99 7
Metamodeling 2 Metamodeling allows for the modeling of modeling languages Analogy to EBNF for programming languages. E.g. C: Use case model <function-definition>::= <function-heading> <function-body> <function-heading>::= <return-type> <function-name> '(' <formal-parameter-phrase> if ( <expression> ) <statement 1> else <statement 2> Metamodeling allows the definition of tailored or domainspecific modeling languages g A metamodel defines the abstract syntax of a modeling language Model : Metamodel = Instance : Class Computer Technology 30/99 Use case metamodel Example 1: Model and Metamodel interface Sensor { operation start():void; operation stop():void; operation measure():float; } interface Controller { operation reportproblem(sensor s, String errordesc ):void; } Interface Operation name : String type : String {ordered} * Parameter name : String type : String * Exception type : String Computer Technology Nico Suchold openarchitectureware /99 2 0 0 4 M a rk u s V ö l t e r Computer Technology -32-/99 8
Example: Architecture centric Metamodel Domain centric Model Computer Technology 34/99 Domain centric Metamodel Computer Technology 35/99 Computer Technology 36/99 9
MOF Meta Object Facility Is an object oriented modeling language Uses UML syntax Meta Object Facility (MOF) Used to formally define UML by the OMG UML 2.0 was also an aiming a redefining the UML formally based on an extended MOF Object Management Group 3 MOF Object Management Group (OMG ) OMG s Mission Since 1989 Develop an architecture, using object technology, for distributed ib t d application integration, ti guaranteeing: reusability of components interoperability & portability basis in commercially available software Specifications freely available Implementations exist Member controlled not for profit Richard Mark Soley 10
OMG s Major Successes Common Object Request Broker Architecture CORBA remains the only language and platform neutral interoperability standard Unified Modeling Language UML TM remains the world s only standardized modeling language Common Warehouse Metamodel CWM TM, the integration of the last two data warehousing initiatives Meta Object Facility OMG s Metalevels describes instance of MOF (Meta-Object M3: Meta-metamodel Facility) describes instance of M2: Metamodel describes instance of M1: Model MOF TM, the repository standard XML Metadata Interchange XMI TM, the XML UML standard Richard Mark Soley describes M0: Instances instance of MOF Example The relationship between metamodel and model Computer Technology 44 /99 11
Class Diagram Object Diagram Level n ECLIPSE MODELING FRAMEWORK Level n + 1 4 Eclipse Modeling in a Nutshell Eclipse Modeling is the umbrella project for all things modeling that happen on the Eclipse platform: The Eclipse Modeling Project focuses on the evolution and promotion of model based development technologies within the Eclipse community by providing a unified set of modeling frameworks, tooling, and standards implementations. EMP Core: EMF The Eclipse Modeling Framework (EMF) serves as the foundation: It provides the Ecore Metametamodel and frameworks and tools around it for tasks such as Editing Transactions Validation Eclipse Modeling is not formally related to OMG, but implements several of theirstandards standards. It is fair to say that many leading edge modeling tools are hosted/developed at Eclipse Modeling. Query Distribution/Persistence ib i i (CDO, Net4j, Teneo) Everything Open Source under the Eclipse Public License 2 0 0 4 Markus Voelter, Bernd Kolb, Peter Friese 12
EMF (2) Modeling framework and code generation facility for building tools and other applications Model specification described in XMI Models can be specified using annotated Java, XML documents and modeling tools EMF (3) Meta model (Ecore)for describing models Reflective API EObject extends Notifier monitor all changes to the object's data Foundation for interoperability with other EMF based tools and applications Provides tools and runtime support for models Set of Java classes for the model Set of adapter classes for viewing editing of the model Basic editor Computer Technology 49/99 Computer Technology 50/99 Domain Specific Language Defines the semantic of the model The notation (concrete syntax) of the DSL can be textual of graphical More important: The DSL s abstract syntax, better known as metamodel Metamodel defines the model elements for domain modeling The DSL s semantics are used to transform the DSL to generalpurpose languages Computer Technology 51/99 13
Definition of Our Own DSL Two approaches for defining a DSL: Alternative 1: Start from scratch based on a predefined meta metamodel (e.g. MOF) Alternative 1 Example: Metamodel for Feature Modeling based on MOF Alternative 2: Use an available metamodel (e.g. UML metamodel) and extend it Alternative 1 Instance of the Metamodel UML Notation: Alternative 2 Extending for example the UML metamodel: Feature Model Notation: It can be used in the following ways: 14
Alternative 2 UML Profiles formally use the meta metamodel to extend the UML metamodel Example Since there aren t many MOF based tools, UML profiles can be used Metamodel elements map to <<stereotypes>> Metamodel attributes map to {tagged values} Metamodel constraints map to modeling constraints/rules UML 2.x Profile Metamodel Enterprise JavaBeans Component Architecture for Enterprise Applications Beans: Entity Session (Stateless/Stateful) Message Remote and Home Access through Interfaces Computer Technology 60/99 15
Example EJB Profile Kinds of Metamodels Architecture centric MDSD Represents the concept of the technical platform Simpler transformations Domain concepts can be added iteratively Used if no sophisticated domain specific metamodel available Domain centric MDSD Useful for product line development in single domain Example: Architecture centric Metamodel Domain centric Metamodel Computer Technology 64/99 16
Multiple Technical Domains One DSL is usually not suitable to describe all aspects of a complex system (e.g. persistence, GUI, ) Domain centric Metamodel (2) Define multiple domains with their metamodel Connect them by small number of gateway meta classes Computer Technology 66/99 How do I come up with a good metamodel? Incrementally! Basedon experience from previous projects, andby mining mining domain experts. A very good idea is to start with a (typically) very well known domain: the target software architecture (platform) Architecture Centric DSLs see below, Cascading How do I come up with a good metamodel? II In order to continuously improve and validate the metamodel for a domain, it has to be exercised with domain experts as well as by the development team. In order to achieve this, it is a good idea to use it during discussions with stakeholders by formulating sentences using the concepts in the meta model. As soon as you find that you cannot express something using sentences based on the meta model, you have to reformulate the sentence the sentence s statement is just wrong you have to update the meta model. 2 0 0 4 M a rk u s V ö l t e r Computer Technology -67-/99 2 0 0 4 M a rk u s V ö l t e r Computer Technology -68-/99 17
How do I come up with a good metamodel? III Example: owns * implements 1 Port Interface Component Required Port Provided Port provides operations defined by provides access to operations defined by MDSD Process A component owns any number of ports. Each port implements exactly one interface. There are two kinds of ports: required ports and provided ports. A provided port provides the operations defined by its interface. A required port provides access to operations defined by its interface. Computer Technology -69-/99 Use Cases for Model Transformations Usually, model transformations are performed as a concretization step. Rules (using terms from the underlying metamodel) specify transformations. Modular Transformations Replace for other domains Transforming a functional analysis model to a design model for a specific platform Specializing general model to a more domain specific model. Creating different views of a model (varying level of detail, varying focus) Extracting subsets oraspects of a model (mainly for analysis and constraint checking) Weaving different models together (e.g. aspects) Replace for other products 18
Transformer Do not base them on concrete syntax (usually error prone) Use three pass approach: Example: Component Based Integration 1. Parse source model into AST 2. Transform source AST into target AST 3. Generate concrete syntax based target model Architectural Aspect of MDSD Model transformations map elements of the source model to elements of the target model a restricted set of well defined concepts is necessary that s a characteristic of a well defined architecture MDSD requires a well defined architecture and forces a conform software development 19