Post on 29-Jan-2016
Automating Software Evolution through Model-
Driven Engineering Troy University8th Annual Computer Science Colloquium on Information TechnologyApril 3, 2007 – Rosa Parks Auditorium
Previous support by DARPA/IXO PCES. Current funding from NSF-CSR and NSF CAREER.
Department of Computer and Information SciencesUniversity of Alabama at Birmingham
S o f t C o m Jeff GrayUAB – CIS Department
Overview of Presentation
Motivation
Background
Domain-SpecificModeling
Video Demos
Research Focus
Model-Driven Software Evolution
Overview of SoftCom
Example Case Studies
Model Transformation Toolsuite• Model Transformation Engine• Transformation Testing Framework• Model Transformation Debugger• Model Version Control• Model-Driven Program Transformation
•Evolution of large legacy apps from models
TransformedBold Stroke C++ codeCommon/Project
Library ofBold Stroke C++
Source Code
DMS Transform
ationRules
DMSvoid BM__PushPullComponentImpl::Update (const UUEventSet& events){ BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events);
unsigned int tempData1 = GetId().GetGroupId(); unsigned int tempData2 = GetId().GetItemId(); std::vector<BM__ClosedComponent*>::iterator devIter =
void BM__PushPullComponentImpl::Update (const UUEventSet& events){
UM__GUARD_EXTERNAL_REGION(GetExternalPushLock()); BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events);
default base domain Cpp~VisualCpp6.pattern UM_GUARD_EXTERNAL_REGION_as_identifier_or_template_id(): identifier_or_template_id = "UM__GUARD_EXTERNAL_REGION".pattern GetExternalPushLock_as_identifier_or_template_id(): identifier_or_template_id = "GetExternalPushLock".pattern ExternalLockStmt(): expression_statement = "\
default base domain Cpp~VisualCpp6.pattern UM_GUARD_EXTERNAL_REGION_as_identifier_or_template_id(): identifier_or_template_id = "UM__GUARD_EXTERNAL_REGION".pattern GetExternalPushLock_as_identifier_or_template_id(): identifier_or_template_id = "GetExternalPushLock".pattern ExternalLockStmt(): expression_statement = "\
ESML Models
Jing Zhang and Jane Linwww.cis.uab.edu/gray/Research/C-SAW/
Software Composition and Modeling Laboratoryhttp://www.cis.uab.edu/softcom/
Hui Wuwww.cis.uab.edu/wuh/DDF
Eclipse DSL Debugging Framework
12
6
1 begin2 left3 down4 up5 right6 end
4
Lexer,Parser
public class Robot{ public static void main(String[] args) { …… //move left x=x-1; time=time+1;
//move down y=y-1; time=time+1; …… } }
3
import java.util.ArrayList;
public class Mapping { ArrayList mapping; public Mapping(){ mapping=new ArrayList(); mapping.add(new Map(1, "Robot.java",2,8)); mapping.add(new Map(2, "Robot.java",10,14)); …… } }
Mapping Component
5
Robot DSL Grammar In ANTLR Notation
Robot DSL
Generated Lexer, and Parser by ANTLR
Robot.java and Mapping.java
Java Command Line Debugger
Robot DSL Debugging Perspective in Eclipse
DebuggerView
DSLEditor
Variables View
Supported by:Eclipse Innovation Grant
• Framework for building debuggers and testing engines for different categories of domain-specific languages
• AspectG is an aspect weaver for grammars
Speech Enabled Software Development
• Assistive technology for disabled programmers• Integrates open source speech recognition with a popular open IDE• Videos and papers available at:
www.cis.uab.edu/info/Eclipse/SpeechClipse
SpeechClipse
Language Independent Refactoring and Aspect Weaving
Suman Roychoudhurry
www.cis.uab.edu/softcom/GenAWeave
Software Composition and Modeling Laboratoryhttp://www.cis.uab.edu/softcom/
Clone Detection and Visualization
Robert Tairas
www.cis.uab.edu/tairasr/clones
• Visualization and analysis of clone detection results from CloneDR as an Eclipse plug-in
High School Outreach at UAB CISMentoring for Science Fair Competitions Summer Robotics Internship
• Weekly mentoring at UAB throughout academic year; students treated like a PhD student with office space
www.cis.uab.edu/gray/Pubs/jerrod-sutton.pdf
Computer Graphics Camp
www.cis.uab.edu/heritage
www.cis.uab.edu/progams/hspcwww.cis.uab.edu/cscamp/
• Week-long summer camp in computer graphics• Students use C++ and OpenGL to create projects focused on geometric modeling, algorithm visualization, and motion design
High School Programming Contest
• Seven-week internship• Students taught Java through series of robotics projects
• May 12, 2007• 2006: 46 students
from 12 schools (Huntsville to Mobile)
• 6 problems in 3 hours• Prizes: Laptop, Xbox,
software, books, gift certificates
• Alice Film Festival!
High School Outreach at UAB CISField Trips to the CIS Department Lectures for Technology Clubs
•3-hour tour of the CIS department:• Several topical lectures• Over 150 students in Fall 2006• Free Pizza lunch!
http://www.cis.uab.edu/field-trips
Alabama K-12 Workshop
http://www.cis.uab.edu/programs/hsws/
• July 31, 2006; 16 state-wide participants
• Purpose: To discuss critical issues needed to raise awareness of computing in Alabama schools.
Dual/Concurrent Enrollment
CIS faculty are available to give topical lectures to classes; if interested, faculty can help bootstrap a club
• Opportunity to earn college credit in the summer by taking the CIS 201 course (Intro to Java)
• 3-4 students each summer• Potential tuition waiver in some cases• Greatly speed up mentoring experience• Prepare students for programming
contest next May• “Concurrent/Dual” enrollment http://www.cis.uab.edu/cs201
SpeechClipse video demo…
http://www.cis.uab.edu/info/Eclipse/SpeechClipse/demo.html
Domain-Specific Modeling
Categories of End-Users
AdminAssistants
Businessman
Auto Factory Worker
Scientist
Spreadsheet
BusinessQuery Systems
Modeling Language
DSL forPhysics
Question
But what is a model?
(Naïve introduction)
Next Few slides adapted from Jean Bezivin….
A very popular model: geographical maps (thanks to Jean Bezivin for this idea)
Models
repOfSystem
2000 Census Map
Aerial Map
Model Road Map
The System
1819 City Plan
Every map has a legend
legend = metamodel
Model
c2
Metamodel
Another Notation (DSL)
Model
Metamodel
c2
Music notation
Sheet music
Executable Model
Power Tab Editor
Two Views:
Traditional notes
Guitar tab
Assisted Drawing Tools (e.g. MS/Visio)
c2Metamodel Model
(thanks to Jean Bezivin for this slide)
Schema definitions: Going “Meta”
Domain-SpecificModeling
ProgrammingLanguage Definition
Database SchemaDefinition
Schema definitionMetamodel for aspecific domain(e.g., Petri Net)
Grammar for a specificlanguage (e.g., Java)
Table, constraint, and storedprocedure definitions for a
specific domain (e.g., payroll database)
Schema instance
Domain model (e.g., Petri Net model of a teller
machine)
A program written in aSpecific language
Intension of a database at aspecific instance in time
(e.g., the June 2006 payrollinstance)
Schema execution Model InterpreterLanguage
compiler/interpreter
Transactions and behavior ofstored procedures
in an executing application
Characteristics of Modeling Languages Each model conforms to its
metamodel A model is a representation
of a system satisfying substitutability For each question that can be
asked of the system, the model produces the same answer Not true for me and road maps!
(from Jean Bezivin)
Observation “One size fits all” approach is appearing to be
inadequate for many end-user needs Too complex and contains “kitchen sink” approach
providing things most users do not need (UML) Current trend is to provide “domain-specific”
modeling languages that are customized to a specific domain Notations and abstractions are exactly what the
users expects; focused on problem space, not technology solution space
But, how to create such modeling languages and environments? Expensive to create from scratch for each domain
ModelInterpretation
Model Interpreters
Models
Modeling Environment
ApplicationDomain
App1
App2
App3
Application Evolution
Environment Evolution
MetamodelingInterface
Metamodel Definition
Meta-LevelTranslation
Model Builder
Background: Domain-Specific Modeling (cont’d)M
etamodel
Model
Interpreter
void CComponent::InvokeEx(CBuilder &builder,CBuilderObject *focus, CBuilderObjectList &selected, long param) {CString DMSRoot = "";DMSRoot = SelectFolder("Please Select DMSRoot Folder:");if (DMSRoot != "") {DMSRulePath = DMSRoot + RULESPATH + "Rules\\";MSRuleApplierPath = DMSRoot + RULESPATH + "RuleApplier\\";AfxMessageBox("DMSRulePath = " + DMSRulePath , MB_OK);CString OEPRoot = "";OEPRoot = SelectFolder("Please Selec
DEFINE
INTERPRET
The Generic Modeling Environment (GME) adopts the DSM approach and provides a plug-in mechanism for extension.
Example DSMLs (not UML)
Model-Driven Software EvolutionModel-Driven Program Transformation with C-SAW
With Jane Lin and Jing Zhang
Supported previously by DARPA PCESand a current NSF CSR and NSF CAREER grant.
The “Twisted Plot” MetaphorThe Problem of Keeping Track of Things in Your Head
• The interactions among characters and overlapping events makes a good novel (“thickness” of plot as a complexity metric)
• The author must take care in preserving, throughout the entire novel, internal consistency within plot
• e.g., a change in the conclusion of the plot may necessitate global changes in all chapters
• Keeping track of all the twists can be difficult because the various concerns of the plot are distributed across multiple chapters
• but…Software development is MANY orders of magnitude more difficult!
Logically Consistent?
…
Chapter 2
Conclusion
Chapter 1
…
Core Focus: Ability to evolve models The size of system models will continue to grow
Models containing several hundreds or even thousands of modeling elements
Others have reported similarly (Johann/Egyed – ASE 2004) A key benefit of modeling
Ability to explore various design alternatives (i.e., “knobs”) E.g., understanding tradeoff between battery consumption
and memory size of an embedded device E.g., scaling a model to 800 nodes to examine performance
implications; reduce to 500 nodes with same analysis… Reducing complexities of the modeling activity
Limit the amount of mouse clicking and typing required within a modeling tool to describe a change Improves productivity and reduces potential manual errors
A general metric for determining the effectiveness of a modeling toolsuite comprises the degree of effort required to make a correct change to a set of models.
Key Challenges: Crosscutting Concerns in Domain-Specific Models
Challenge 1: Crosscutting Models Base models become constrained to capture a
particular design Concerns that are related to some global property are
dispersed across the model Solution: Model Weaving
C-SAW is an aspect-oriented weaver at the modeling level
Changeability???
Multiple Levels
of HierarchyReplicatedStructures
ContextSensitive
A
B
c d eB
c d e
F
B
c d e
Crosscutting Constraints
Challenge 2: Fidelity Between Models and Code Changes to models must have a causal connection to underlying source Parsing large legacy systems and performing required adaptations is too difficult for each
new system to be encountered Solution: Model-Driven Program Transformation
A model interpreter generates DMS transformation rules from properties described in models
Challenge 1: Solved with Aspect-Oriented ModelingCrosscutting Constraints in Real-Time/Embedded Models
Implemented as a GME plug-in to assist in the rapid adaptation and evolution of models by weaving crosscutting changes into models.
C-SAW: Model Transformation Engine
ECL Interpreter
ECL Parser
Defines
MetaModel
Source Model
Mo
de
ling
AP
Is
Defines
ECL Transformation Specifications
Defines CopyAtom strategy CopyAtom
Mo
de
ling
AP
IsAspect
Weaving
Target Model
Key Challenge 2: Evolution of legacy models and code
∆MM: The changes made to the meta-models∆M: The changes reflected in the domain models∆I: The changes reflected in the legacy source
Legacy Source1
Model1
Metamodel1
Define
Interpret
Legacy Sourcen
Modeln
Metamodeln
Define
Interpret
Legacy Source0
Model0
Metamodel0
Define
Interpret
∆M 1
∆MM 1
∆I 1
∆M 2
∆MM 2
∆I 2
∆M n
∆MM n
∆I n……
……
……
Based
on
What about other artifacts of the modeling process during metamodel evolution?Interpreters, constraints, model transformations…
1. Model weaving to explore design alternatives more rapidly
• Design decisions crosscut model hierarchy
• Difficult to change models to new configuration
• Design decisions captured as higher level policy strategies and weaved into models
2. Model driven program transformation• Ensures causal connection between
model changes and represented source code of legacy system
• Assists in legacy evolution from new properties specified in models
• Model interpreters generate transformation rules to modify source
3. Experimentation:Boeing’s Bold Stroke Application
• Apply original Bold Stroke C++ source code and generated transformation rules to DMS; result is a transformed version of Bold Stroke that is consistent with the model specification
void BM__PushPullComponentImpl::Update (const UUEventSet& events){ BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events); unsigned int tempData1 = GetId().GetGroupId(); unsigned int tempData2 = GetId().GetItemId(); std::vector<BM__ClosedComponent*>::iterator devIter = devices_.begin(); std::vector<BM__ClosedComponent*>::iterator endIter = devices_.end(); for (; devIter != endIter; ++devIter) { BM__ClosedComponent* component = *devIter; const UUIdentifier& id = component->GetId(); if (idInEventSet(id, events)) { const BM__ClosedFunctionalFacet& facet = component->ProvideClosedFunctionalFacet(); BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData1"); tempData1 += facet.GetData1(); BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData2"); tempData2 += facet.GetData2(); } } data1_ = tempData1; data2_ = tempData2;}
void BM__PushPullComponentImpl::Update (const UUEventSet& events){
UM__GUARD_EXTERNAL_REGION(GetExternalPushLock()); BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events); unsigned int tempData1 = GetId().GetGroupId(); unsigned int tempData2 = GetId().GetItemId(); std::vector<BM__ClosedComponent*>::iterator devIter = devices_.begin(); std::vector<BM__ClosedComponent*>::iterator endIter = devices_.end(); for (; devIter != endIter; ++devIter) { BM__ClosedComponent* component = *devIter; const UUIdentifier& id = component->GetId(); if (idInEventSet(id, events)) { const BM__ClosedFunctionalFacet& facet = component->ProvideClosedFunctionalFacet(); BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData1"); tempData1 += facet.GetData1(); BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData2"); tempData2 += facet.GetData2(); } }
UM__GUARD_INTERNAL_REGION; log.add(“data1_=”+data1_); data1_ = tempData1; data2_ = tempData2;
log.add(“data2_=”+data2_);}
DMS Xform Rules
Base C++ Source CodeTransformed
C++ Code
GME ModelModeling Aspect
1
2
3
Solution: Two-Level Aspect Weaving
Weaved Model
//show("Data fields exist. Add two concurrency atoms.");//add the first concurrency atomconcurrencyAtom1 := addAtom("Concurrency", "InternalLock");concurrencyAtom1.setAttribute("Enable", "1");// "1" is true, "0" is falseconcurrencyAtom1.setAttribute("LockType", "Thread Mutex");concurrencyAtom1.setAttribute("LockStrategy", "Internal Locking");//add the second concurrency atomconcurrencyAtom2 := addAtom("Concurrency", "ExternalLock");concurrencyAtom2.setAttribute("Enable", "1");// "1" is true, "0" is falseconcurrencyAtom2.setAttribute("LockType", "Thread Mutex");concurrencyAtom2.setAttribute("LockStrategy", "External Locking");
Case Study:Bold Stroke Product Line
Background Context Mission-control software for Boeing military aircraft
under development since 1995 (F-15/F-18) CORBA event-based systems Thousands of components implemented in over 4 million
lines of C++ code Key Challenges
Difficult to evolve the underlying source representation to address new requirements; impossible to determine, a priori, all of the future adaptation requests
Difficult to migrate the source representation to newer component models
Example: C-SAW Assertion Strategy
default base domain Cpp~VisualCpp6. pattern assertStmt() : statement = "assert(data1_>200);". pattern aspect(s:statement_seq): statement_seq = " \assertStmt\(\){ \s }". pattern joinpoint(id:identifier): qualified_id = "\id :: Update". rule precondition(ret:decl_specifier_seq, id:identifier, p:parameter_declaration_clause, s:statement_seq): function_definition -> function_definition = "\ret \joinpoint \(\id\)(\p){\s}" -> "\ret \joinpoint \(\id\)(\p){\aspect\(\s\)}" if ~[modsList:statement_seq .s matches "\:statement_seq \apect\(\modsList\)"]. public ruleset applyrules = { precondition }.
void BM__ClosedEDComponent:: Update(const UUEventSet& events)
{
assert(data1_>200); // <- Precondition BM_CompInstrumentation:: EventConsumer(GetId(), "Update", events); unsigned int tempData1 = GetId().GetGroupId(); unsigned int tempData2 = GetId().GetItemId(); //* REMOVED code for Real-time Event Channel //* REMOVED actual variable names (proprietary) data1_ = tempData1; data2_ = tempData2;
assert(data1_<500); // <- Postcondition
}
strategy FindData1(){ atoms()->select(a | a.kindOf()=="Data" and a.name()=="data1_")->AddConds();}
strategy AddConds(){ declare p : model; declare data, pre, post : atom; data := self; p := parent();
pre:=p.addAtom("Condition","PrecondData1_"); pre.setAttribute("Kind", "PreCondition"); pre.setAttribute("Expression", "data1_>200"); p.addConnection("AddCondition", pre, data); post:=p.addAtom("Condition", "PostcondData1_"); post.setAttribute("Kind", "PostCondition"); post.setAttribute("Expression", "data1_<500"); p.addConnection("AddCondition", post, data); }
aspect Start(){ rootFolder().findFolder("ComponentTypes"). models()->select(m|m.name().endWith("Impl"))->FindData1(); }
Video Demonstration:C-SAW and Model-Driven Program Transformation
http://www.cis.uab.edu/gray/Research/C-SAW/video-demo.htm
Evolving a black-box data recorder…
New Challenge: Replicating a Base Model to Address Scalability Issues
Model Scalability Base models must be replicated to explore alternative designs Model elements need to be replicated, in addition to all
required connections
Single UAV Model Three UAV Model
Example applications Event QoS Aspect Language
Specify properties of event-based communication within a DRE (e.g., mission-computing avionics)
System Integration Modeling Language Specify properties of high-performance physics
experiments
UAV QoS Language (not described here) Specify properties of video QoS in an Unmanned
Aerial Vehicle
A language to address performance issues among distributed systems using network patterns
Scaling the Event QoS Aspect Languagestrategy expandSite(site, numGW : integer){ findModel("Site " + intToString(site)).addGateWay_r(1, numGW);}
strategy addGateWay_r(curr, numGW : integer){ if (curr <= numGW) then addGateWay(curr); addGateWay_r(curr+1, numGW); endif;}
strategy addGateWay(num : integer){ declare site_gw : atom; declare ec : model;
site_gw := addAtom("CORBA_Gateway", "CORBA_Gateway" + intToString(num)); ec := findModel("Event_Channel"); addConnection("LocalGateway_EC", site_gw, ec); }
Conclusion and Ongoing Work Benefits of Model-Driven Engineering
Captures domain abstractions that are appropriate for an end-user; enables analysis at higher levels of abstraction
Model transformations assist in evolution tasks that would be too tedious and error prone to do manually
Ongoing Work Framework for testing the correctness of model
transformations Model differentiation algorithms “Model Transformation by Example” Version control of models at proper abstraction level Evolution of other modeling artifacts in an automated manner
Related Web Pages
http://www.cis.uab.edu/Research/C-SAW/Contains papers, downloads, video demos
C-SAW
SoftCom Research Lab
http://www.cis.uab.edu/softcom
K-12 Outreach Activities
http://www.cis.uab.edu/gray/OutreachContains papers, posters, and video demos
Department of Computer and Information SciencesUniversity of Alabama at Birmingham
S o f t C o m
Development Forces100+ DevelopersLengthy product lifecyclesComponent orientedMillions of SLOC1,000s of component instances
Domain ForcesEmbeddedDistributedHRT + SRTMission CriticalStringent performance requirements
Avionics Mission Computing Context
Wendy Roll, Boeing
PCES-1 Focus: Simulating Joint OEP Scenario
Design
Initial Implementations Complete for:• 1 UAV Case• 3 UAV Case (@ Demonstration)• 30 UAV Case (With Weaver)
Synthesis
Execution
Modeling of Adaptive QoS Systems•Adaptive Behaviors•Environmental stimulus•Middleware interfaces
Generative technology•Matlab and Stateflow simulations•QuO CDL