TOOLS USA '99 Interaction Schemata: Compiling Interactions to Code Neeraj Sangal, Edward Farrell, Tendril Software, Inc, Westford, MA

Slides:



Advertisements
Similar presentations
Model Driven Generative Programming Reza Azimi February 6, 2003 ECE1770: Trends in Middleware Systems.
Advertisements

Dept. of Computer Science A Runtime Assertion Checker for the Java Modeling Language (JML) Yoonsik Cheon and Gary T. Leavens SERP 2002, June 24-27, 2002.
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
16/11/2015 9:05 AM6/11/2015 9:05 AM6/11/2015 9:05 AMFunctions Functions A function consists of: Name Name Arguments (also called parameters) Arguments.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
 2007 Pearson Education, Inc. All rights reserved C Functions.
Computer Science CS425/CS6258/23/20011 The Architecting Phase Class diagrams are further refined in this phase of development Object diagrams are created.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CS 201 Functions Debzani Deb.
 2007 Pearson Education, Inc. All rights reserved C Functions.
© Copyright Eliyahu Brutman Programming Techniques Course.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
(C) 1998 Tendril Software Inc. StructureBuilder Tendril Software Inc. OOPSLA ‘98 Demo Neeraj Sangal, President Tendril Software Karl.
UML class diagrams and XML schemas Karl Lieberherr UBS AG Northeastern University.
Impact Analysis of Database Schema Changes Andy Maule, Wolfgang Emmerich and David S. Rosenblum London Software Systems Dept. of Computer Science, University.
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
Computer Science Victoria University of Wellington Copyright: david streader, Victoria University of Wellington Simple Design COMP
PRESTO: Program Analyses and Software Tools Research Group, Ohio State University STATIC ANALYSES FOR JAVA IN THE PRESENCE OF DISTRIBUTED COMPONENTS AND.
Chapter 3 Introduction to Collections – Stacks Modified
Dale Roberts Procedural Programming using Java Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Integrating Independent Components with On-Demand Remodularization based on OOPSLA 2002 paper by Mira Mezini Klaus Ostermann Prepared by Karl Lieberherr.
Chapter 5 Class Design. The Deliverables of the Class Design Process Class diagrams are further refined in this phase of development Object diagrams are.
Phoenix Software Projects Larry Beaty © 2007 Larry Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is.
Copyright © 2012 Pearson Education, Inc. Chapter 6: Functions.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
AP/DJ AP: a generic technology DJ: a low-learning-curve implementation of AP.
Generics and Collections. Introduction Generics New feature of J2SE 5.0 Provide compile-time type safety Catch invalid types at compile time Generic methods.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Demeter Aspects We study techniques for the emerging area of Aspect-Oriented Software Development and focus on the following areas:  Aspectual Collaborations.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Structures and Classes Version 1.0. Topics Structures Classes Writing Structures & Classes Member Functions Class Diagrams.
DJ: traversal-visitor-style programming in Java Josh Marshall/ Doug Orleans Want to add more on traversal through collections and Aspectual Components.
Lorenz: Visitor Beans: An Aspect-Oriented Pattern Aspect-oriented pattern: describes a solution to a tangling problem in a particular context.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 6: Functions.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Good for DJ over Java Extending traversals for b..* –returning a single object instead of a collection (Find) –modifying the collection (Add, Delete)
Andrey Karaulov, Alexander Strabykin Institute for System Programming Russian Academy of Sciences SYRCoSE: Spring Young Researchers Colloquium on Software.
Chapter – 8 Software Tools.
Lecture 4 – Function (Part 1) FTMK, UTeM – Sem /2014.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
Unified Modeling Language (UML)
Computer Science Victoria University of Wellington Copyright: david streader, Victoria University of Wellington Simple Design COMP
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
AP/DJ AP: a generic technology
Good for DJ over Java Extending traversals for collections (b..*)
Demeter Aspects Who We Are Aspectual Collaborations
CSCI 161: Introduction to Programming Function
Compiler Design 18. Object Oriented Semantic Analysis (Symbol Tables, Type Checking) Kanat Bolazar March 30, 2010.
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
6 Chapter Functions.
AP/DJ AP: a generic technology
Analysis models and design models
Data Structures & Algorithms
Corresponds with Chapter 5
Presentation transcript:

TOOLS USA '99 Interaction Schemata: Compiling Interactions to Code Neeraj Sangal, Edward Farrell, Tendril Software, Inc, Westford, MA Karl Lieberherr, and David H. Lorenz College of Computer Science Northeastern University Boston, MA 02115

Northeastern University Outline oMotivation  Generate Code From Interaction Diagrams oThe Problem  Diagrams are not precise oConcept Formulization  Interaction Schemata oTwo Implementation Approaches  Code generation approach  Structure Builder (SB)  Generative approach  DJ (Demeter Java)

Northeastern University Motivation: Round Trip

Northeastern University Interactions Diagrams // Class: Library // File: Library.java /** * (c) Northeastern University book dl Generated Method (2) */ void upwardTransportationExample(Book book) { // SBgen: Calls generated method on Book (2) SBObject sbsecondUser = new SBObject(); User firstUser = book.getNextUser(sbsecondUser); User secondUser = (User)sbsecondUser.getValue(); // SBgen: End Call // SBgen: Action Execute method on User (5) firstUser.notifyBookReady(); // SBgen: Action Execute method on User (6) secondUser.alertYouAreNext(); } // Class: Book // File: Book.java Generated Method (4), created by Library.up(Book) (Library.2,-2) */ User getNextUser(SBObject sbsecondUser) { // SBgen: Action Execute method on Book (3) User firstUser = getFirstUser(); // SBgen: Action Execute method on Book (4) *Goal: Generating Code From Interaction Diagrams

Northeastern University The Problem oProblem  UML interaction diagrams are not precise enough to prescribe code.  UML interaction diagrams are difficult to keep up-to-date with the code. oSolution Approaches  Code generation approach  Structure Builder: A Java design tool  Method generated with mark-ups  Generic approach  DJ: A research project  Interactive traversals using JGL and Reflection

Northeastern University What's Missing in Interaction Diagrams oNo object "book-keeping" oIgnores scope and visibility issues oIgnores object transportation issues oOther details: method parameters, return types, collections to iterate over, etc. *Sub-Goal: Make Interaction Diagrams Complete Code Generation Approach: Structure Builder (SB) Generative Approach: DJ (Demeter Java) and then or

Northeastern University Association Role Class Example: Library System Cardinality

Northeastern University Where did user come from? Object "Book-Keeping" oLibrary.checkIn(Copy copy, UID uid) What is the signature of removeCopy ? *Generated methods must have correct signature and return type.

Northeastern University What is the scope of book ? Scope and Visibility book is out of scope! *Objects have scope even in Interaction Diagrams

Northeastern University Where did copy come from? Downward Object Transportation  copy must be transported down through removeCopy() Returned by findCopy() Used by release()

Northeastern University Where did resUser come from? Upward Object Transportation Generated by getFirstOnReservationList() Called for notifyBookReady()  resUser must be transported up through getNextUser()

Northeastern University Object Transportation - Wrapper firstUser and secondUser have to be transported up through getNextUser() *Second object is passed back through a wrapper.

Northeastern University Textual Representation oNested Methods a.m1() { b.m2() } oConditional if (test) { a.m1(); }

Northeastern University Formalization of Actions oSyntax for actions  [ interactor  interactor ... ]. actionName ( exp1, exp2,... ) return( type1 retexp1, type2 retexp2,... ) {... } oBasic actions  Method call  Conditional  Iteration oAdditional predefined actions on collections  Find  Add  Remove oUser defined actions  Anything Can contain other actions The scope of each returned variable is limited to being inside the innermost enclosing conditional or iterative action.

Northeastern University Sequence Diagram for CheckIn

Northeastern University Interaction Schema for CheckIn Library.checkIn(UID uid, Copy copyId) { [library  users  uid]. find (uid'current == uid) return (User users'current as theUser) [theUser  borrows  copyId]. remove (copyId'current == copyId) return (Copy borrows'current as theCopy) [theCopy].getBook() return (Book book as theBook) [theBook  reserves]. remove (reserves'index == 0) return (User reserves'current as theReserver) if (theReserver != null) { [theReserver  holds]. add (theCopy) [theReserver]. notify (theCopy); } }

Northeastern University Interactions Involve Multiple Classes C1 C2 C3 C4 C5 Interact-1 Interact-2Interact-3 Interact-4 C1 C2 C3 C4 C5

Northeastern University void checkIn(UID uid, Copy copyId) { User user = null; Object tmpKey; Enumeration i = users.keys(); while(i.hasMoreElements()) { tmpKey = i.nextElement(); user = (User)users.get(tmpKey); if (user.uid==uid) break; } Copy copy = user.checkIn(copyId); Book book = copy.getBook(); User resUser = book.checkIn(); if (resUser != null) { resUser.checkIn0(copy); resUser.notify(copy); } } User checkIn() { User resUser = null; int size = reserves.size(); if (size > 0) { resUser = reserves.elementAt(0); reserves.removeElementAt(0); } return resUser; } Copy checkIn(Copy copyId) { Copy copy = null; int i, size = borrows.size(); for (i=size-1; i>=0; i--) { Copy tmpVar = (Copy)borrows.elementAt(i); if (tmpVar.getId() == copyId) { copy = tmpVar; borrows.removeElementAt(i); break; } return copy; } void checkIn0(Copy copy) { holds.addElement(copy); } Method generated in class Library class User class Book Method Generation Approach oFour methods generated in three classes  Library  User  Book

Northeastern University StructureBuilder Approach: Generated Method Dialog Actions Action Properties Available Objects Action on Selected Object

Northeastern University Object Transportation firstUser.notifyBookReady() is missing information: red color indicates a problem

Northeastern University Object Transportation User links the missing information: firstUser

Northeastern University DJ Approach oBuild on Demeter/Java experience  AP Library, visitor organization  Create class graph from Java programs  Generalized traversals: find, add,... oName traversals  new TravSpec(" From Library to User ").container(this)); oCompute traversals dynamically  Container c = new TraversalGraph(Main.classGraph, new TravSpec(…)); oMain observation  Actions like add, find, and delete appear in Generic Programming (GP) as methods of container interfaces (e.g., JGL).  DJ attempts to reuse those generic algorithms. Better to have an easy- to-use less-powerful system than a harder-to- use more-powerful system.

Northeastern University The checkIn Method in DJ void checkIn(UID uid, Copy copyId) { Container LibraryToUserContainer = new TraversalGraph( Main.classGraph, new TravSpec("From Library to User").container(this)); User user = Finding.findIf( LibraryToUserContainer, new FieldEquals("uid",uid)); if (user == null) return; Container UserToCopyContainer = new TraversalGraph( Main.classGraph, new TravSpec("From User through borrows to Copy").container(user)); Copy copy = Finding.findIf( UserToCopyContainer, new FieldEquals("copyId",copyId)); if (copy == null) return; Removing.remove(UserToCopyContainer,copy); Container CopyToUser = new TraversalGraph (…) ; Container UserToCopyHoldsCont = new TraversalGraph( Main.classGraph, new TravSpec("From User through holds to Copy").container(user)); User reserver = (User)CopyToUser.remove(CopyToUser.elements()); if (reserver != null) { UserToCopyHoldsCont.add(copy); reserver.notify(copy); } }

Northeastern University Conclusions oPossible to generate code from interaction diagrams.  Interactions must be made complete.  Possible to preserve simplicity of interaction diagrams and yet make them complete. oInteraction diagrams can be made adaptive by addition of traversal semantics. oActions allow programmers to try out different types of data structures in a structure-shy manner. oDiagrams like programs need to deal with basic programming issues like scope, visibility, and transportation.

Northeastern University Future oCombine the two approaches. oDomain specific action types. oImproved object caching techniques. oSuggestions for changes to internal data structures for improved performance.

Northeastern University Additional Information Tendtril Software  Free product evaluation download  Northeastern University  Download papers and source code 

The End

Northeastern University Code for Transporting One Object Up // Class: Library // File: Library.java /** * (c) Northeastern University book dl Generated Method (2) */ void up(Book book) { // Call generated method on Book (2) User firstUser = book.getNextUser(); // Action Execute method on User (5) firstUser.notifyBookReady(); } // Class: Book // File: Book.java Generated Method (4) */ User getNextUser() { // Action Execute method on Book (3) User firstUser = getFirstUser(); // Return firstUser return (firstUser); }

Northeastern University Generated Code for Upward Transportation of Two Objects // Class: Library // File: Library.java /** * (c) Northeastern University book David Lorenz Generated Method (2) */ void upwardTransportationExample(Book book) { // SBgen: Calls generated method on Book (2) SBObject sbsecondUser = new SBObject(); User firstUser = book.getNextUser(sbsecondUser); User secondUser = (User)sbsecondUser.getValue(); // SBgen: End Call // SBgen: Action Execute method on User (5) firstUser.notifyBookReady(); // SBgen: Action Execute method on User (6) secondUser.alertYouAreNext(); } // Class: Book // File: Book.java Generated Method (4), created by Library.up(Book) (Library.2,-2) */ User getNextUser(SBObject sbsecondUser) { // SBgen: Action Execute method on Book (3) User firstUser = getFirstUser(); // SBgen: Action Execute method on Book (4) User secondUser = getSecondUser; // SBgen: Returns firstUser sbsecondUser.setValue(secondUser); return firstUser; // SBgen: End Return }