Interaction Schemata: Compiling Interactions to Code - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Interaction Schemata: Compiling Interactions to Code

Description:

TOOLS USA '99. Interaction Schemata: Compiling Interactions to Code ... UML interaction diagrams are not precise enough to prescribe code. ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 30
Provided by: davidh142
Learn more at: https://www2.ccs.neu.edu
Category:

less

Transcript and Presenter's Notes

Title: Interaction Schemata: Compiling Interactions to Code


1
Interaction SchemataCompiling Interactions to
Code
Neeraj Sangal, Edward Farrell, Tendril Software,
Inc, Westford, MA http//www.tendril.com
Karl Lieberherr, and David H. Lorenz College of
Computer Science Northeastern University Boston,
MA 02115
TOOLS USA '99
2
Outline
  • Motivation
  • Generate Code From Interaction Diagrams
  • The Problem
  • Diagrams are not precise
  • Concept Formulization
  • Interaction Schemata
  • Two Implementation Approaches
  • Code generation approach
  • Structure Builder (SB)
  • Generative approach
  • DJ (Demeter Java)

3
Motivation Round Trip
4
Interactions Diagrams
  • Goal Generating Code From Interaction Diagrams

5
The Problem
  • Problem
  • UML interaction diagrams are not precise enough
    to prescribe code.
  • UML interaction diagrams are difficult to keep
    up-to-date with the code.
  • Solution 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

6
What's Missing in Interaction Diagrams
  • No object "book-keeping"
  • Ignores scope and visibility issues
  • Ignores object transportation issues
  • Other details method parameters, return types,
    collections to iterate over, etc.
  • Sub-Goal Make Interaction Diagrams Complete

and then
or
7
Example Library System
Class
Association
Cardinality
Role
8
Object "Book-Keeping"
  • Library.checkIn(Copy copy, UID uid)

Where did user come from?
What is the signature of removeCopy?
  • Generated methods must have correct signature and
    return type.

9
Scope and Visibility
What is the scope of book?
book is out of scope!
  • Objects have scope even in Interaction Diagrams

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

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

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

13
Textual Representation
  • Nested Methods
  • a.m1() b.m2()
  • Conditional
  • if (test) a.m1()

14
Formalization of Actions
  • Syntax for actions
  • interactor ? interactor ? ....actionName(exp1,ex
    p2,...) return(type1 retexp1, type2
    retexp2,...) ...
  • Basic actions
  • Method call
  • Conditional
  • Iteration
  • Additional predefined actions on collections
  • Find
  • Add
  • Remove
  • User defined actions
  • Anything

The scope of each returned variable is limited to
being inside the innermost enclosing conditional
or iterative action.
Can contain other actions
15
Sequence Diagram for CheckIn
16
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.ad
d(theCopy) theReserver.notify(theCopy)

17
Interactions Involve Multiple Classes
Interact-1
C1
C4
C2
C3
C5
Interact-4
Interact-2
Interact-3
C1
C4
C2
C3
C5
18
Method Generation Approach
  • Four methods generated in three classes
  • Library
  • User
  • Book

19
StructureBuilder Approach Generated Method
Dialog
Available Objects
Actions
Action on Selected Object
Action Properties
20
Object Transportation
firstUser.notifyBookReady()is missing
information red color indicates a problem
21
Object Transportation
User links the missing information firstUser
22
DJ Approach
Better to have an easy-to-use less-powerful
system than a harder-to-use more-powerful system.
  • Build on Demeter/Java experience
  • AP Library, visitor organization
  • Create class graph from Java programs
  • Generalized traversals find, add, ...
  • Name traversals
  • new TravSpec("From Library to User").container(thi
    s))
  • Compute traversals dynamically
  • Container c new TraversalGraph(Main.classGraph,
    new
    TravSpec())
  • Main 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.

23
The checkIn Method in DJ
  • void checkIn(UID uid, Copy copyId)
  • Container LibraryToUserContainer new
    TraversalGraph( Main.classGraph,
    new TravSpec("From Library to User").container(thi
    s))
  • 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",copy
    Id))
  • 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(Co
    pyToUser.elements())
  • if (reserver ! null) UserToCopyHoldsCont.add(
    copy) reserver.notify(copy)

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

25
Future
  • Combine the two approaches.
  • Domain specific action types.
  • Improved object caching techniques.
  • Suggestions for changes to internal data
    structures for improved performance.

26
Additional Information
  • StructureBuilder _at_ Tendtril Software
  • Free product evaluation download
  • www.tendril.com
  • DJ _at_ Northeastern University
  • Download papers and source code
  • www.ccs.neu.edu/research/demeter

27
The End
28
Code for Transporting One Object Up
// Class Book // File Book.java / _at_SBGen
Generated Method (4) / User getNextUser() //
Action Execute method on Book (3) User firstUser
getFirstUser() // Return firstUser return
(firstUser)
  • // Class Library
  • // File Library.java
  • /
  • (c) Northeastern University
  • _at_param book
  • _at_author dl
  • _at_SBGen 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()

29
Generated Code for Upward Transportation of Two
Objects
  • // Class Library
  • // File Library.java
  • /
  • (c) Northeastern University
  • _at_param book
  • _at_author David Lorenz
  • _at_SBGen 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)
  • // Class Book
  • // File Book.java
  • / _at_SBGen 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
Write a Comment
User Comments (0)
About PowerShow.com