Metamodelling & Metaprogramming. Lena Buffoni

Similar documents
Metamodelling & Metaprogramming. Lena Buffoni

Metamodeling and Metaprogramming

Metamodeling and Metaprogramming

New Programming Paradigms

The Art of Metaprogramming in Java. Falguni Vyas Dec 08, 2012

Atelier Java - J2. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Certification In Java Language Course Course Content

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

Inheritance and Polymorphism

Metamodeling with Metamodels. Using. UML/MOF including OCL

Lecture 2 summary of Java SE section 1

Metamodeling and Metaprogramming Seminar

INTROSPECTION. We need to begin with a more basic concept called type introspection

Better Metadata Management through Better Metamodels

Software Project Seminar VII: Tools of the Craft. 23 march 2006 Jevgeni Kabanov

Introduction to Dependable Systems: Meta-modeling and modeldriven

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Reflection (in fact, Java introspection)

Enum Types. Built-in support for types of discrete values Advantages over C++ s enum: Type-safety Body can include methods and fields

Coverage of Part 2. A Brief Introduction to Java for C++ Programmers: Part 2. import: using packages

CSC324 Principles of Programming Languages

CSCE 314 Programming Languages

interface MyAnno interface str( ) val( )

2. Metamodelling and Metaprogramming

Getting started with Java

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Preview from Notesale.co.uk Page 3 of 36

ATL Transformation. Catalogue of Model Transformations

Some @SuppressWarnings

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Lecture 2: Java & Javadoc

Studying software design patterns is an effective way to learn from the experience of others

Javadocing in Netbeans (rev )

Annotation Hammer Venkat Subramaniam (Also published at

P2: Advanced Java & Exam Preparation

What is Metamodeling and Code Generation All About

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

CS 200 More Classes Jim Williams, PhD

Lecture 9 : Basics of Reflection in Java

Knowledge Discovery: How to Reverse-Engineer Legacy Systems

Automating Model Composition for Design Verification

Language engineering and Domain Specific Languages

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

Character Stream : It provides a convenient means for handling input and output of characters.

Inheritance. Notes Chapter 6 and AJ Chapters 7 and 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Orccad, a Model Driven Architecture and Environment for Real-Time Control. Soraya Arias Florine Boudin Roger Pissard-Gibollet Daniel Simon

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Java Reflection

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

CH. 2 OBJECT-ORIENTED PROGRAMMING

Plan. Language engineering and Domain Specific Languages. Language designer defines syntax. How to define language

ADT: Eclipse development tools for ATL

Course Wrap-up. CSC207 Fall 2015

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Chapter 2: The Object-Oriented Design Process

Dominique Blouin Etienne Borde

Program Fundamentals

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Object-Oriented Concepts

Metaprogramming. 2. Metadata, Metamodelling, and. Mandatory Literature. Simulation, Vol. 12, No. 4, October 2002, Pages

52. Staged Software Architectures with Staged Composition

.Net Technologies. Components of.net Framework

CISC836: Models in Software Development: Methods, Techniques and Tools

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Whole Platform Foundation. The Long Way Toward Language Oriented Programming

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Program generation for schema-based, typed data access

How to make a "hello world" program in Java with Eclipse *

Java Magistère BFA

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

JAVA: A Primer. By: Amrita Rajagopal

Dominique Blouin Etienne Borde

BLU AGE 2009 Edition Agile Model Transformation

The Extensible Markup Language (XML) and Java technology are natural partners in helping developers exchange data and programs across the Internet.

Rules and syntax for inheritance. The boring stuff

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Using Scala for building DSL s

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

Model driven Engineering & Model driven Architecture

Professor Yedidyah Langsam

Quizz Master AISL year wednesday 26 october 2016

JML. Java Modeling Language

Big Java Late Objects

Reusing Classes. Hendrik Speleers

Inheritance (Part 5) Odds and ends

The Art of Metaprogramming in Java. Abdelmonaim

CISC-124. Passing Parameters. A Java method cannot change the value of any of the arguments passed to its parameters.

Inheritance Introduction. 9.1 Introduction 361

* Corresponding Author

Compositional Model Based Software Development

Presentation of Open Simulation Architecture and Open Simulation Instrumentation Framework

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

Model-Based Social Networking Over Femtocell Environments

SSE3052: Embedded Systems Practice

1. A Remote Proxy helps to hide all the low-level details of exception handling from the proxy Client.

Advanced Tool Architectures. Edited and Presented by Edward A. Lee, Co-PI UC Berkeley. Tool Projects. Chess Review May 10, 2004 Berkeley, CA

Programming in the Large II: Objects and Classes (Part 2)

Transcription:

Metamodelling & Metaprogramming Lena Buffoni lena.buffoni@liu.se

What is a model? A representation of a concept, phenomenon, relationship, structure, system from the real world Used to communicate, test scenarios, predict behavior Is an abstraction Always simplified to some degree Maps, toy- cars, stochastic economic models are all examples of models

A building model Renters view Tax collectors view Electricians view Builders view Realtors view Designers view Each view concentrates on modeling specific aspects

From model to meta-model - vehicles How can we generalize the concepts? Car Model (in Modelica) Truck model

Generalizing through inheritance Super-class vehicle X wheels a steering wheel a clutch

What if we throw an airplane in the mix? Super-class vehicle X wheels a steering wheel a clutch

GeneralizaOon through metamodelling Aerodynamic Model 1 Vehicle Engine 1..n Actuator 1..n Sensor 1..n Reason in terms of categories on a higher abstracoon level

Another example : Modeling Methodologies Classical model V model Can we deduce a general modeling methodology? Agile model

4 layers of meta-modeling Conforms to Meta-meta model (language specificaoon) Conforms to Meta-model (modeling language) Not the only way to view things! Model (car class) Conforms to Represented by System (car instance) Jean Bézivin, On the unificaoon power of models, 2005.

UML and Meta-modeling MOF (Meta Object Faculty) a standard for specifying UML meta-models Provides language constructs for specifying a DSL meta-model Mainly based on Object-Oriented constructs: package, classes, properties (attribute and reference), and (multiple) inheritance. Specificities: composition, opposite...

Meta-programming Operations on the program itself We have a program model abstract syntax tree Simplified example: A := B + 3; assignement Led-side assignment Right-Side expression Variable Expression A Binary Operator +

When? At compile time : preprocessing Macros in C optimization annotations templates in C++ Compilers can be seen as metaprograms

When? At runtime : interpreters Dynamic component configuration and reconfiguration Java reflection API

To what extent? Introspection - look at the structure of the program Generate documentation Verify composability Reflection - manipulate the structure of the program Dynamically configure components Adapt component behavior over time

How? At a meta-level: A separate language for processing the program At the same level as the program itself (reification) Concepts of a meta-level can be represented at the base level. Ex: Reflection API in Java Class c = A.getClass();

Java reflecoon API Dynamically select which method to call public class ConfigurablePrint { void printonlinux(){} void printonmac() {} void printonwindows(){} }

Java reflecoon API public sta?c void main(string[] args) { try{ //load the AppTest at runome Class cls = Class.forName("ConfigurablePrint"); Object obj = cls.newinstance(); Class [] noparams = {}; //call the printit method String methodname = ""; if(getsystem() == SystemType.WINDOWS) methodname = "printonwindows"; else if(getsystem() == SystemType.MAC) methodname = "printonmac"; else methodname = "printonlinux"; Method method = cls.getdeclaredmethod(methodname, noparams); method.invoke(obj, (Object[])null); }catch(excep?on ex){ ex.printstacktrace(); }}

Meta-programming one step further A hack to language extension? add a backwards_for to a language change how inheritance works Meta-meta-programming? compilers of compilers

Component Markup languages Markup languages distinguish between the basic programming directives and meta instructions LaTeX mixes text and typesetting directives HTML, XML Annotations, Javadoc tags is Java Attributes in C++

AnnotaOons in Java @Override public String tostring() { Predefined annotaoons return "This is String Representation of current object."; } Javadoc annotaoons /** * The HelloWorld program. * * @author Lena * @version 1.0 */ public class HelloWorld { } }

AnnotaOons in composioon @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) //on class level public @interface PreferencePolicy { public enum Policy { WEAK, MEDIUM, STRONG } Policy priority() default Policy.MEDIUM; }

Component composioon Markup is important in component composition Mark methods that will be exposed to the client Version compatibility verification Define configuration and initialization parameters

Summary Metamodelling : from specific models towards models of models Metaprogramming : operating on the structure of the code itself Meta-information is essential for component composition