1
1
Stan JarzabekNational University of Singapore
Simple yet Effective Reuse beyond Components
Problems we can Solve withProblems we can Solve withPowerPower--GenericsGenerics
31st International Conference on Software Engineering
Tutorial 24
2ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
TemplatesTemplatesA template represents a group of similar classes in generic, adaptable form:
With power-generics, we want to do the same for:– Any family of similar software products– Any group of similar program structures
Files, directories, components, patterns of components, etc.
Stack <T>Queue<T>Set<T>Sort <T>Search<T>
IntStack
template
instantiation
ShortStack
IntQueue
ShortStack
2
3ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What is What is powerpower--genericsgenerics??Role Playing Games (RPG) on mobile phones
The four RPGs are similar
RPGs running on many mobile phones are also similar
Jump FeedingDigGem
Hunt
Let’s have a generic RPG!
4ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What is a What is a generic RPGgeneric RPG??A generic RPG is a parameterized RPG that can be adapted to DigGem, Haunt, …Key: observe repetitions across RPGs– similarities and differences
variant features
generic RPG
game
derivation
parameters
DigGemDigGem
HuntHunt
JumpJump
FeedingFeeding
3
5ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What is What is powerpower--genericsgenerics??For any group of similar program structureswe want a generic, adaptable form– similar files, directories, …, software products
CreateStaffUser Interface
CreateStaffBusiness Logic
Staff Table Project Table
CreateProjectBusiness Logic
CreateProjectUser Interface
Task Table
CreateTaskBusiness Logic
CreateTaskUser Interface
Create[E].UI
Create[E].BL
Create[E].DB
6ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Questions:Questions:1. How are power-generics useful? In what situations
we can benefit from them?– RAD? Maintenance? Reuse?
2. How to achieve power-generics?3. How do they compare to classical software reuse
– Architecture-centric, component based
4. How to make power-generics a practical software development/maintenance method?
5. Any evidences?
4
7ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Reuse beyond componentsReuse beyond componentsAre you using or considered any of these techniques:
Classes and components.NET, JEEModel-driven approachDesign patternsPreprocessing, macrosConfiguration files, parameter tablesAnt, make, other build toolsXVCL – helps to achieve similar goals– XML-based Variant Configuration Language– parameterized, adaptable components
8ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Is XVCL relevant to you?Is XVCL relevant to you?Do you develop multiple software product variants for:– different customers– market segments– platforms
Does this involve much repetitive work?Do you maintain all these product variants?Does this involve much repetitive work?
If some answers are ‘yes’ – you already are in reuse business, software Product Lines (SPL)
5
9ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
WhatWhat’’s our challenge in s our challenge in
software development?software development?
10ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What do these structures have in common?What do these structures have in common?
They are large and complex structuresThey were built without modern technologies!But it took huge effort and cost to build them– 27 years to build each pyramid– thousands people died building them
12th century
2000 BC
10th - 15th century887 moailarge stone statues20th century
6
11ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
IsnIsn’’t software situation similar?t software situation similar?We can develop large and complex software:– IBM OS (1960’s)– military software is huge, complex, must be reliable– WINDOWS (close to 100 million LOC) – most businesses today depend on complex software systems
Important questions:How can we develop software at lower cost, with higher success rate? – Do we have right tools for that?
How can we tackle even more complex systems?Ultra-Large-Scale Systems: systems of systems (billions LOC)
12ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Software engineering challengesSoftware engineering challengesdespite new technologies and many successes:
Software projects are often unpredictable– many projects run out of schedule and budget, 25% of large projects are
never completed
Maintenance cost up to 80% of computing cost– change is hard, evolution is hard
Reuse has not become a standard practice
Outsourcing: a leading software development technique – US$ 100 billion in 2005, growing trend
7
13ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Questions:Questions:1. How are power-generics useful? In what
situations we can benefit from them?– RAD? Maintenance? Reuse?
2. How to achieve power-generics?3. How do they compare to classical software reuse
– Architecture-centric, component based
4. How to make power-generics a practical software development/maintenance method?
5. Any evidences?
14ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
ExamplesExamples
8
15ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
RoleRole--Playing Games (RPG)Playing Games (RPG)
The four RPGs are similarRPGs running on many mobile phones are also similar
A software Product Line (SPL)
Jump FeedingDigGem
Hunt
Let’s reuse!
16ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Market forces: good reasons to reuseMarket forces: good reasons to reuseSimilar RPGs must run on many types of mobile devices and must perform well
Many brands and models of mobile devices– differ in platforms, communication protocols, display
units, memory size, etc.
– 640 x 200 color screen vs. 100 x 80 mono display
– 80M memory vs. less than 100kb memory
– J2ME MIDP2.0 vs. MIDP1.0
Development cost, time-to-market are important
9
17ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Explosion of RPG product variantsExplosion of RPG product variants
A nightmare and opportunity for mobile software vendors:
How are RPGs similar? common featuresHow are RPGs different? variant features
Climb FeedingDigGem Hunt
Nokia E65 Nokia E70 Nokia E90 W890i W910i Motorola ….
RPGs
mobile phones
18ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Conventional techniquesConventional techniques
Climb FeedingDigGem Hunt
Nokia E65 Nokia E70 Nokia E90 W890i W910i Motorola ….
RPGs
mobile phones
reuse with game engines
reuse with power-generics
portability with power-generics
portability with platform mechanisms
Game engines and platform mechanisms
manualworkmanual
work
10
19ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Project Collaboration Project Collaboration EnvirEnvir (PCE)(PCE)
PCE stores staff, project data, facilitates project progress monitoring, communication in the team, etc.
e.g., Module Staff: allows the user to create, edit, and update data about staff members, assign staff members to projects, etc.
20ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
PCE product variantsPCE product variants
PCEMyTeam
PCESmall-1
PCESmall-2
PCESmall-3
PCEBig-1
PCEBig-2
PCEBig-3
PCEBig-2-Dept1
PCEBig-2-Dept2
PCEBig-2-Dept3
PCEAgile
PCEWaterfall
PCEAgile-Small
PCEAgile-Big
reuse
11
21ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Comments on product evolutionComments on product evolutioneach PCE product variant implements:– common features shared by all PCEs– features shared with some of the PCEs– some unique new features
implementation of the same feature across various PCEs may vary
we would like to reuse as much as possible
How do we manage product evolution?How do we manage product evolution?
22ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Conventional reuseConventional reuse
12
23ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
An RPG Product Line: RPGAn RPG Product Line: RPG--PLPL
Understand what’s similar and what’s different among RPGs
Design a reusable Product Line Architecture – PLA
Develop (derive) new RPGs from the RPG-PLA (reuse)
Maintain existing RPGs via RPG-PLA
HuntDigGem JumpDigGem
Jump
FeedingFeeding
24ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Two dimensions of variability– Game functionality variants– Mobile phone platform variants
Variability in Variability in RPGsRPGs
13
25ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
PLA design and product derivationPLA design and product derivation
Domain experts
PLA
product developmentProduct development team
Feedback
userrequirements
DigGem
for Nokia
domain engineering
domainknowledge existing systems in a
domain
PLA design and evolution
26ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Reuse: RPGReuse: RPG--PLAPLAHow are RPGs similar and different? – business-oriented analysis variability in a domain– observe repetitions across similar RPGs
Design generic PLA that can be reused across games after suitable adaptations
variant features
DigGemDigGem
HuntHunt
JumpJump
FeedingFeeding
RPG-PLA
game
derivation
reusable componentsreusable components
14
27ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What are our strategies for What are our strategies for
managing product variants?managing product variants?
28ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Strategies for evolution and reuseStrategies for evolution and reusestrategy 1: brut-force evolution
– ignore similarities among PCEs and develop and maintain each PCE as a separate product
strategy 2: ad hoc reuse by copy/modify– store PCE component versions in CVS or SVN– copy and modify files and directories to reuse already
implemented features– implement new features needed in new product variant
what problems?
15
29ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Problems of ad hoc reuseProblems of ad hoc reuse
many PCE products need be maintained
many component versions in CVS
– which components implement which features?
– which component versions will fit new PCE?
manual, error-prone and expensive reuse:
– component selection, adaptation, integration, testing
30ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Strategy 3: allStrategy 3: all--inin--one productone productimplement all PCEs in a single, parameterized product
by setting parameters we obtain required PCE
PCEPCE--11
PCEPCE--22
PCEPCE--33
PCEPCE--44
16
31ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Techniques for allTechniques for all--inin--one strategyone strategy
conditional compilation
commenting out feature code
configuration parameter files/tables
build tools such as Ant, make …
design patterns
Model-Based Development
….
32ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
ExamplesExamplesfor( int i=0; i < yearTemp.size(); i++ ) { . . .#If ( FeatureConfiguration.DelegationLock&& FeatureConfiguration.OperationLock )// Code when both features are selected#else if ( FeatureConfiguration.DelegationLock )// Code when delegationLock is selected#else if ( FeatureConfiguration.OperationLock )// Code when operationLock is selected}. . .
/* code for PCEAgile ….. */
/* code for PCEBig ….. */
17
33ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Techniques: AntTechniques: Ant<project name="webfee" basedir="." default="main">. . .<target name="copy‐src" depends="create‐folders">. . .<!‐‐ Copy java classes of Feature DownloadPaymentDetail ‐‐><copy todir="${src.dir}"><fileset dir="${core‐src.dir}/${DownloadPaymentDetail}" /></copy>. . .</target><target name="copy‐webpage" depends="create‐folders">. . .<!‐‐ Copy webpages of Feature DownloadPaymentDetail ‐‐>
<copy todir="${web‐root.dir}"><fileset dir="${core‐webpage.dir}/${DownloadPaymentDetail}" /></copy>. . .</target>. . .<project>
34ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Problems of strategy 3Problems of strategy 3Many inter-related parametersOne feature implemented in many placesDifficult to understand code instrumented with many parametersTime-consuming, error-prone customizationsDifficult to maintain, enhanceAs the number of product variants grows,
problems accumulate
18
35ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
1 function editable_form($form, $id=0, $relModID=null, $Container=null, $ContainerID=null)
2 { global $module_name, $attributes; If($form==”Edit”){ $msg=” Please modify the $module_name data”; $title="Edit $module_name"; $nextAction=”saveChanges”; } elseif ($form==”createInsideContainer”){ $msg=” Please enter the $module_name data”; $title="New Composed $module_name "; $nextAction=”saveInstanceInsideContainer”; } elseif ($form=="copy"){ $msg="Please enter the ".$module_name." data"; $title="Copy ".$module_name; $nextAction="saveCopy"; }else{ $msg=” Please enter the $module_name data”; $title="New $module_name "; $nextAction=”saveInstance”; }
3 If($form==”Edit”){ //check user has rights to edit instance… } elseif ($form==”createInsideContainer”){ //check user has rights to edit container… }elseif($form=="copy"){ //retrieve data to be copied }
4 Title($title); <form><table> <tr><td> echo($msg); </td></tr> <tr><td>Title</td> <td><input name="Data[Title]" type="text"
value=" if(($form=="Edit")||($form=="copy")) echo $result['Title'];"></td></tr> If($form==”Edit”){ // retrieve data, show link to container, if exists… } elseif ($form==”createInsideContainer”){ //show link to container }
5 foreach($attributes as $attribute) <tr><td>echo $attribute; </td> <td><input name="Data[echo $attribute;]" type="echo ($module_name=="File" && $attribute=="FileUpload")? "file":"text";" value="if(($form=="Edit")||($form=="copy")) echo $result[$attribute];" > </td></tr> }
6 If($form==”Edit”){ <tr><td>Change Remark</td> <td><textarea name="Remark" ></textarea></td></tr> } <input type="hidden" name="cmd" value="$nextAction"> }
Code with productCode with product--specific variants specific variants
36ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What else can we do to easier What else can we do to easier
manage product variants?manage product variants?
19
37ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Do domain analysisDo domain analysisanalysis of requirements for many PCEs
each PCE involves entities and operations
PCE modules implement operations for entities
entities:
operations:
Staff Project Product
Create Edit Delete Display Save
38ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Set up product architectureSet up product architecturefirst step towards systematic reuse: – set up product architecture shared by all product variants
(software Product Line architecture)
– some feature can be mapped into components
variant features
DigGemDigGem
HuntHunt
JumpJump
FeedingFeeding
reusable componentsvariant features
PCEPCE--11
PCEPCE--22
PCEPCE--33
PCEPCE--44
PCE
development
reusable components
20
39ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Modules for Staff, Project, Modules for Staff, Project, ……
40ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Similarity/difference analysisSimilarity/difference analysisunderstand the exact similarities and differences among PCE
Operations Create for Staff, Project, Product, etc. are similar but also different
entities:
operations:
Staff Project Product
Create Edit Delete Display Save
21
41ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Group of similar operations: Group of similar operations: Create[ECreate[E]]
CreateStaff.BLvalidateStaff()
Staff.DBaddStaff()Staff Table
Project.DBaddProject()Project Table
CreateProject.BLvalidateProject()
CreateStaff.UIcreateStaff()
CreateProject.UIcreateProject()
Product.DBaddProduct()Product Table
CreateProduct.BLvalidateProduct()
CreateProduct.UIcreateProduct()
CreateStaff CreateProject CreateProduct
42ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Group of similar operations: Group of similar operations: EEddiitt[E[E]]
EditStaff.BLvalidateEditStaff()
Staff.DBeditStaff()Staff Table
Project.DBeditProject()Project Table
EditProject.BLvalidateEditProject()
EditStaff.UIeditStaff()
EditProject.UIeditProject()
Product.DBeditProduct()Product Table
EditProduct.BLvalidateEditProduct()
EditProduct.UIeditProduct()
EditStaff EditProject EditProduct
22
43ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Idea: Generic PCE modulesIdea: Generic PCE modules
generic PCE modules in XVCL
Create[E].UI
Create[E].BL
Create[E].DB
Edit[E].UI
Edit[E].BL
Edit[E].DB
productdevelopment
UI for CreateStaff
BL for CreateStaff
Staff Table Project Table Product Table
BL for CreateProject
BL for CreateProduct
UI for CreateProject
UI forCreateProduct
UI for EditStaff
BL for EditStaff
Staff Table Project Table Product Table
BL for EditProject
BL for EditProduct
UI for EditProject
UI forEditProduct
UI for …
BL for …
… … …
BL for …
BL for …
UI for …
UI for…
PCE variants
Create[E].UI
Create[E].BL
Create[E].DB
Edit[E].UI
Edit[E].BL
Edit[E].DB
44ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
A simple mechanism for unrestricted generic design
Automated by XVCL Processor
Used in sync with conventional OO/component technologies:
– C, C++, Java, ASP, PHP, JEE, .NET, etc.
Public domain, available at http://xvcl.comp.nus.edu.sg
XVCL method supported by XVCL Workbench
Based on Bassett’s frames, Frame Technology™, Netron, Inc
XVCLXVCLXMLXML--based Variant Configuration Language based Variant Configuration Language
23
45ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
XVCL approach to reuse:XVCL approach to reuse:
Avoid repetitions:1. Observe similarities across product variants
similar program structures of any kind
2. Represent them in generic, adaptable form (XVCL)
We apply parameterization and generic design– in addition to component and architecture design
46ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
A glimpse at technical A glimpse at technical
underpinsunderpins
24
47ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Unify repetitions across Unify repetitions across PCEsPCEswe observe repetitions (similarities) across PCEsS-i : similar program structures– functions, classes, files, components, component configurations,
subsystems
PCEPCE--11S-1
S-4
S-3
S-2 PCEPCE--22
PCEPCE--33
PCEPCE--44
generic PCE
S-gen
1 2 3 4
variant features
48ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Migration into XVCLMigration into XVCL
generic S-gen represents both S-1 and S-2S-gen
PCE-PLA in XVCL
PCE-1
S-1
S-1 and S-2 are similar program structures in games PCE-1 and PCE-2
specs of how to adapt S-gen to obtain S-1 and S-2
XVCL Processor
PCE-2
S-2
25
49ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Managing PCE variants with XVCLManaging PCE variants with XVCL
variant features
PCEPCE--
PCEPCE
PCEPCE--
members of PCE-PL
PCE-PLA in XVCL
Create[E].UI
Create[E].BL
Create[E].DB
Edit[E].UI
Edit[E].BL
Edit[E].DB
productderivation
XVCL Processor
50ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Generic PCE with XVCLGeneric PCE with XVCL
SPC
Create [E] Edit [E]
Level 1:
Level 2:
Level 3:
others
Create[E].BL Create[E].DBCreate[E].UI Edit [E].BL Edit [E].DBEdit [E].UI
Level 4:
Level 5:
generic classes
generic methods
generic operations(patterns of component
generic operationcomponents
in SPC, we specify entities and actions we need in PCE and entity-level customizations
here we specify a component pattern for each actions and customizations for UI, BL and DB components
here we specify customizations per entity action: CreateStaff, CreateTask, EditStaff,EditTask, etc.
26
51ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
feature diagram
Buffer
Element Type(T)
Access Mode(AM)
Memory AllocationScheme (MS)
Direct
Native
View Buffer(VB)
Read-Only Writable
Non-direct
Non-nativeLittle-Endian Big-Endian
doublefloat
char
byte
short
longint
Alternativefeatures
Mandatoryfeatures
Byte Order(BO)
Optionalfeatures
specificationof custom PCEs
SPC PCE-1 SPC PCE-2 SPC PCE-3 SPC PCE-4 SPC PCE-5
generic, reusable x-frames
PCE-Module
Create [E] Edit [E] others
Create[E].BL Create[E].DBCreate[E].UI Edit [E].BL Edit [E].DBEdit [E].UI
generic classes
generic methods
generic operations(patterns of components)
generic operationcomponents
feature selection
XVCL Processor
custom PCE products
PCE-2
PCE-3
PCE-4
PCE-1
52ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
What can we achieve What can we achieve
in XVCL way?in XVCL way?
27
53ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Web Portal in ASP/XVCLWeb Portal in ASP/XVCLby ST Electronics (Info-Software Systems) Pte Ltd
Details in : Pettersson, U., and Jarzabek, S. “Industrial Experience with Building a Web Portal Product Line using a Lightweight, Reactive Approach,” ESEC-FSE'05, European Software Engineering Conference and ACM SIGSOFTSymposium on the Foundations of Software Engineering, Sept. 2005, Lisbon, pp. 326-335
54ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
4
4XVCL-based development
ASP / XVCL WPProduct Line Architecture
From PCE to WP Product LineFrom PCE to WP Product Line
Personal Portal(home)
Conventional ASP Development
PCE
1
5
New PortalVariants
(generated)People Tracking
(business product - SARS)
2
PCE Variants(office)
3 6
REACTIVE
28
55ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Experiences from ASP/XVCL project:Experiences from ASP/XVCL project:
STEE has built and maintains over 20 different portals – based on XVCL-enabled Product Line architecture
Short time (less than 2 weeks) and small effort (2 persons) to start seeing the benefitsHigh productivity in building new portals with XVCL– 60% - 90% reduction of code needed to build a new portal– estimated eight-fold reduction of effort
Reduced maintenance effort for released portals– for the for first nine portals, managed code lines was 22% less
than the original single portal
56ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
technology impact – benefit: balancing cons and pros– impact on maintenance – a critical factor in technology evaluation
where do we place technologies on this scale?
technology Ttechnology THLLHLLOOOOJ2EE, .NET, J2EE, .NET, ……
overhead of T:overhead of T:learning curvelearning curvecomplexitycomplexityproblems inducedproblems induced
problems solved by Tproblems solved by T
highhigh--level programming languages HLLlevel programming languages HLL((much productivity gainmuch productivity gain))
cons
pros
Impact of technology on productivityImpact of technology on productivity
29
57ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Trade offsTrade offsXVCL applied with good results:– only in small- to medium-size projects– agile development methods
Integration with standard processes is a challenge– XVCL Workbench– technology transfer and methodological
guidelines
58ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Other applications of XVCLOther applications of XVCLMobile phone games
Zhang, W. and Jarzabek, S. “Reuse without Compromising Performance: Experience from RPG Software
Product Line for Mobile Devices,” 9th Int. Software Product Line Conference, SPLC’05, September
2005, Rennes, France, pp. 57-69
Business financial systems– Fudan Wingsoft Ltd, used at Fudan University, Shanghai Jiaotong University,
Zhejiang University, Harbin Institute of Technology, Sichuan University, and
Chongqing University
Java Buffer libraryJarzabek, S. and Li, S. ”Unifying clones with a generative programming technique: a case study,”
Journal of Software Maintenance and Evolution: Research and Practice, July/August 2006,
pp. 267-292, also ESEC-FSE’03 paper that received ACM Distinguished Paper Award
30
59ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
ReferencesReferencesXVCL, XML-based Variant Configuration Language, xvcl.comp.nus.edu.sgJarzabek, S. Effective Software Maintenance and Evolution: Reused-based Approach,
Auerbach, CRC Press Taylor and Francis, May 2007Patterson, U., and Jarzabek, S. “Industrial Experience with Building a Web Portal Product Line
using a Lightweight, Reactive Approach,” ESEC-FSE'05, European Software Engineering Conference and ACM SIGSOFT Symposium on the Foundations of Software Engineering, ACM Press, September 2005, Lisbon, pp. 326-335
Zhang, W. and Jarzabek, S. “Reuse without Compromising Performance: Experience from RPG Software Product Line for Mobile Devices,” 9th Int. Software Product Line Conference, SPLC’05, September 2005, Rennes, France, pp. 57-69
Yang, J. and Jarzabek, S. “Applying a Generative Technique for Enhanced Reuse on J2EE Platform,” 4th Int. Conf. on Generative Programming and Component Engineering,GPCE'05, Sep 29 - Oct 1, 2005, Tallinn, Estonia, pp. 237-255
Basit, H. A., Jarzabek, S. “Data Mining Approach for Detecting Higher-level Clones in Software,” to appear in IEEE Trans. on Soft. Eng.
Yali Zhang, Hamid Abdul Basit, Stan Jarzabek, Dang Anh, and Melvin Low “Query-based Filtering and Graphical View Generation for Clone Analysis,” Proc. 24th IEEE Int. Conf. on Software Maintenance, ICSM’08, Beijing, September 2008, pp. 376-385
60ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Q & AQ & A
31
61ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Mobile phone softwareMobile phone softwareapplied to manage RPG product variantsreuse without compromising performance
Zhang, W. and Jarzabek, S. “Reuse without Compromising Performance: Experience from RPG Software Product Line for Mobile Devices,” 9th Int. Software Product Line Conference, SPLC’05, September 2005, Rennes, France, pp. 57-69
62ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Financial softwareFinancial softwaredeveloped by Fudan Wingsoft Ltd
product variants used at over 80 institutions– Fudan University, Shanghai Jiaotong University,
Zhejiang University, Harbin Institute of Technology, Sichuan University, and Chongqing University
all-in-one product– conditional compilation, comments, config files, Ant
migrated to XVCL
32
63ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Buffer library, JDK 1.5Buffer library, JDK 1.5
Jarzabek, S. and Li, S. ”Unifying clones with a generative programming technique: a case study,”Journal of Software Maintenance and Evolution: Research and Practice, July/August 2006, pp. 267-292, also ESEC-FSE’03 paper that received ACM Distinguished Paper Award
64ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Java/XVCL vs. original classesJava/XVCL vs. original classes
LOC reduction: 68% Java code, 72% (code + comments)in Java/XVCL, we count both Java code and XVCL commands
LOCLOC
0
2000
4000
6000
8000
10000
12000
14000
Java code Java code with comments
Java/XVCLJava/XVCL original classesoriginal classes
33
65ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Migration product variants Migration product variants
to XVCLto XVCL
Similarity analysis of product variantsSimilarity analysis of product variants
66ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Migration products to XVCLMigration products to XVCL1. Understand commonalities and differences among PCEs
2. Set up component architecture for PCEs
3. Build generic XVCL structures for groups of similar software structures in PCE
4. Derive PCEs from generic PCE in XVCLDigGem
Hunt
Jump
Feeding
PL members
XVCL-PLA
productderivation
XVCL Processor
34
67ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone Miner and AnalyzerClone Miner and AnalyzerClone Miner (CM) detects similar program structures:
first, CM detects simple clones – a token based clone detector, similar to CCFindernext, CM applies data mining techniques to find configurations of simple clones as candidates for structural clones
Clone Analyzer (CA)helps find meaningful clones
– graphical presentations of similarity situation, queries---------------------------------------------------------------------Clone Miner: Basit, A.H. and Jarzabek, S. “Detecting Higher-level Similarity Patterns in
Programs,” ESEC-FSE'05, September 2005, Lisbon, pp. 156-165; ICSM,08, CM/CA technology summary
68ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Find and analyze similaritiesFind and analyze similarities
Clone Miner (CM):find similar code fragments first (simple clones)find recurring simple clone patterns raise level of clone detection, iterate
Clone Analyzer (CA)query-based filtering, visualization
35
69ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone MinerClone Miner
CMCM++
Domain analysisDomain analysislegacy PCElegacy PCE
CreateStaff.BLvalidateStaff()
Staff.DBaddStaff()Staff Table
Project.DBaddProject()Project Table
CreateProject.BLvalidateProject()
CreateStaff.UIcreateStaff()
CreateProject.UIcreateProject()
Product.DBaddProduct()Product Table
CreateProduct.BLvalidateProduct()
CreateProduct.UIcreateProduct()
70ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone MinerClone Miner
Legacy systemSimple clones in files Locate recurring patterns of clones
1
9876
5432
1312 14
10
11 15
1,4,8,10,11,12
1,4,7,8,10,11,12
2,5,9,13,15
source code filessource code files
36
71ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone MinerClone Miner
1
8
11 10
12
4
7 13 5
9 15
2
Domain AnalysisSimilarity abstraction: identify similar files
Create Entity Form files
Entity Business
Logic files
Identify collaborations
72ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone MinerClone Miner
High Level Similarity Pattern
1 104 8 7
151392 5
XVCL Representationcreate project form
create staff form
create task form
Project logic
Task logic
Staff Logic
create [X]
form
[X] logic
37
73ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Clone Analyzer: Clone Analyzer: comparing clonescomparing clones
73
74ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek 74
Clone Analyzer: Clone Analyzer: visualizing similaritiesvisualizing similarities
38
75ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
XRF XRF –– migration facilitymigration facilitya Workbench for migrating products to XVCL
76ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Toy example: similar Account classesToy example: similar Account classes
class SavingsAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Savings Account”);
}}
class CurrentAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Current Account”);
}}
class LoanAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Loan Account”);
}}
39
77ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
x-frame Accountclass @className {
public static void main(String[] args) {<while messages>
System.out.println(“@messages”);</while>}
}
class SavingsAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Savings Account”);
}}
x-frame SPC<set className = SavingsAccount /><set messages = This is a bank account, Savings Account/><adapt Account />
XVCL Processor
Savings
Loan
Current
Generic class AccountGeneric class Account
78ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Deriving Current AccountDeriving Current Account
x-frame Accountclass @className {
public static void main(String[] args) {<while messages>
System.out.println(“@messages”);</while>}
}
class CurrentAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Current Account”);
}}
x-frame SPC<set className = CurrentAccount /><set messages = This is a bank account, Current Account/><adapt Account />
XVCL Processor
40
79ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Deriving three Account classesDeriving three Account classesclass SavingsAccount {
public static void main(String[] args) {System.out.println(“This is a bank account”);System.out.println(“Savings Account”);
}}
x-frame SPC<set className = SavingsAccount, CurrentAccount,
LoanAccount /><set common = This is a bank account/><while className>
<select option = className><option SavingsAccount >
<set messages = @common, Savings Account /><adapt Account />
<option CurrentAccount ><set messages = @common, Current Account /><adapt Account />
<option LoanAccount ><set messages = @common, Loan Account /><adapt Account />
</select></while>
class CurrentAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Current Account”);
}}
class LoanAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Loan Account”);
}}
x-frame Accountclass @className {
public static void main(String[] args) {<while messages>
System.out.println(“@messages”);</while>}
}
XVCL Processor
80ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
<adapt><adapt>--driven composition of xdriven composition of x--framesframes
SPC
Saving.s
Account
Current.s
Start
XVCL Processor
processing path
generated classes
End ! SavingAccount {
…
}
CurrentAccount {
…
}
other
LoanAccount {
…
}
how does this compare to generics/templates so far?
41
81ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
XVCL Processor operationXVCL Processor operation<adapt> command instructs the processor to:
1. process the specified x-frame and all x-frames adapted from there
2. perform customizations of all the adapted x-frames as specified in <adapt> body
3. interpret any XVCL commands embedded in visited x-frames
4. emit the result to the specified output file
82ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Evolution of classesEvolution of classes
42
83ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Foreign currency accountForeign currency accountwe need class FcAccount for foreign currencyclass FcAccount needs some extra methods as compared to other account classes
class FcAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Foreign Account”);
}// extra methods for FcAccount
int convert () { … }int interest () { … }
}
84ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
x-frame Accountclass @className {
public static void main(String[] args) {<while messages>
System.out.println(“@messages”);</while>
}<break extra-methods>}
class SavingsAccount {}
x-frame SPC<set className = SavingsAccount, CurrentAccount, LoanAccount, FcAccount /><set common = This is a bank account/><while className>
<select option = className><option SavingsAccount >
<set messages = @common, Savings Account /><adapt Account />
<option CurrentAccount ><set messages = @common, Current Account /><adapt Account />
<option LoanAccount ><set messages = @common, Loan Account /><adapt Account />
<option FcAccount ><set messages = @common, Foreign Account /><adapt Account >
<insert extra-methods>// extra methods for Foreign Account:
int convert () { … } int interest () { … }
</insert></select>
</while>
XVCL Processor
class LoanAccount {}
class CurrentAccount {}
class FcAccount {public static void main(String[] args) {
System.out.println(“This is a bank account”);System.out.println(“Foreign Account”);
}// extra methods for Foreign Account:
int convert () { … } int interest () { … }
}
43
85ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
x-frame SPC<set v = X /><set Type = Byte, Char, Double, Float, Int, Long, Short /><adapt A><adapt B>
<insert b>code spc
</adapt>
x-frame A<while Type>
class @TypeBuffer {<select option = elmntType >
<option Byte> @Type b;
<option Char>@Type c;
</select></while>
x-frame B<set v = Y />
reference to v: @v
<adapt C>
<insert b>code bbbb
</adapt>
x-frame C
<break b>
code cccc
</break>
adapts
how does this compare to generics/templates?
86ICSE’09 Tutorial 24 Copyright (C) 2009 Stan Jarzabek
Q & AQ & A
--- The End ---