cross-application fan-in analysis for finding application-specific concerns
Post on 04-Feb-2016
22 Views
Preview:
DESCRIPTION
TRANSCRIPT
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Cross-application Fan-in Analysis for Finding Application-specific Concerns
Makoto IchiiTakashi Ishio
Katsuro Inoue
Osaka University
1AOAsia 42008/12/2
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Coding pattern detection Automatic detection of crosscutting concerns helps
Finding refactoring opportunities Understanding application-specific coding rules
Fung: Coding pattern detection tool [Ishio, 2008][Miyake, 2007]
Detects coding patterns including crosscutting concerns from an application using a data mining technique
Basic idea: “a crosscutting concern code frequently appears across an application”
2008/12/2 AOAsia 4 2
[Ishio, 2008] T. Ishio. H. Date, T. Miyake and K. Inoue, "Mining Coding Pattern to Detect Crosscutting Concerns in Java Programs", Proc. WCRE2008, 2008
[Miyake, 2007] T. Miyake, T. Ishio, K. Taniguchi, K. Inoue, "Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining", Proc. AOASIA3, 2007
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Example of coding pattern Coding pattern
An ordered sequence of method calls and control statements that frequently appears in source code.
Process of coding pattern detection
2008/12/2 AOAsia 4 3
…if (log.isDebugEnabled()){ log.debug(getMessage());}… …String status = getStatus();if (log.isDebugEnabled()){ log.debug(status);}… …if (log.isDebugEnabled()){ log.debug("QBK");}…
…isDebugEnabled()IFgetMessage()debug()END_IF……getStatus()isDebugEnabled()IFdebug()END_IF……isDebugEnabled()IFdebug()END_IF…
1: isDebugEnabled()2: IF3: debug()4: END_IF
Source code Method call sequence Coding patternparse & normalizeSequentialpattern mining
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Needs for application-specific concerns Detected coding patterns include generic idioms
Idioms also frequently appear across code base Less interesting to developers who need application-
specific knowledge
2008/12/2 AOAsia 4 4
1: isDebugEnabled()2: IF3: debug()4: END_IF
1: iterator()2: hasNext()3: LOOP4: next()5: hasNext()6: END_LOOP
Logging
Target application Detected patterns
Iterator idiom
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Filtering approach:cross-application fan-in analysis Key Idea
Generic idioms appear in various applications Application-specific patterns appear in a few applications
Measure how widely a class/pattern is used across applications
– “Universality” metric
2008/12/2 AOAsia 4 5
1: iterator()2: hasNext()3: LOOP4: next()5: hasNext()6: END_LOOP
1: isDebugEnabled()2: IF3: debug()4: END_IF
Logging
Iterator idiom
Appears in only two applications
Appears in almost all applications
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Approach overview Collect various applications
Including target application Analyze the use-relation between the classes in the applications Measure universality metric for each classes Filter out the patterns comprising only universally-used classes.
2008/12/2 AOAsia 4 6
1. …………………………2. …………………………3. …………………………4. …………………………5. …………………………………
1: iterator()2: hasNext()3: LOOP4: next()5: hasNext()6: END_LOOP
1: isDebugEnabled()2: IF3: debug()4: END_IF
1: activate2: IF3: deactivate4: END_IF
1: indexOf2: lastIndexOf3: substring
1: contains2: IF3: get4: END_IF
1: iterator()2: hasNext()3: LOOP4: next()5: hasNext()6: END_LOOP
1: isDebugEnabled()2: IF3: debug()4: END_IF
1: activate2: IF3: deactivate4: END_IF
1: indexOf2: lastIndexOf3: substring
1: contains2: IF3: get4: END_IF
Target application
Application collection Use-relation between classes List of universally-used classes
Detected patterns Filtered patterns
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Cross-application use-relation An extension of ordinal static use-relation analysis between classes in an
application. Build a use-relation graph
Node: class Edge: static use-relation between classes
Kinds of use-relation Inheritance, Method call, Field access, Instantiation and Variable/Parameter
declaration
2008/12/2 AOAsia 4 7
Source code Use-relation graph
Warehouse
Liquor
WarehouseApp
WarehouseApp
class Liquor { long price; String name; …}
class Warehouse { … Liquor liq = new Liquor(); …}
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Cross-application use-relation Analyze use-relation between classes across application
borders Analyze intra-application use-relation
in the same way with the case of single application If there are several copies of “used class” in different applications,
create edges to all of them
2008/12/2 AOAsia 4 8
Warehouse
Liquor
WarehouseApp
Store
Liquor
StoreApp
Paper
Shelf
A copy of Liquor in WarehouseApp
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Class fan-in and application fan-in
2008/12/2 AOAsia 4 9
Warehouse
Liquor
WarehouseApp
Store
Liquor
StoreApp
Paper
Shelf
Class fan-in of a class c The number of classes using c
Application fan-in of a class c The number of applications using c
App Class CFI AFI
WA Warehouse 0 0
Liquor 3 2
SA Store 0 0
Shelf 1 1
Liquor 3 2
Paper 2 1
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
The Class Universality Metric Class universality of a class c
Represents how widely a class is used From many classes / applications
2008/12/2 AOAsia 4 10
App Class CFI AFI
WA Warehouse 0 0
Liquor 3 2
SA Store 0 0
Shelf 1 1
Liquor (copy) 3 2
Paper 2 1
Univ.
0
1.2
0
0.39
1.2
0.61
|)log(|
)1log(
|)log(|
)1log()(tyuniversali
A
a
C
ic cc
Frequently-used universally
Frequently-used locally
ic: class fan-in of c; ac: application fan-in of c;
|C|: total number of classes; |A|: total number of applications
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
The Pattern Universality Metric Pattern universality of a pattern p
The minimum universality value of the classes whose methods are invoked in p
A universal pattern comprises only universal classes
2008/12/2 AOAsia 4 11
Coding pattern
Class Univ.
Collection 0.72
Iterator 0.77
Involved classes
1: iterator()2: hasNext()3: LOOP4: next()5: hasNext()6: END_LOOP
Pattern universality = 0.72
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case studiesCase Study 1
Measure class universality value of actual classes
Case Study 2 Measure pattern universality value of coding patterns
detected by Fung
2008/12/2 AOAsia 4 12
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 1 – OverviewQuestions
Q.1 What kind of classes have high universality?Q.2 Can universality distinguish classes widely used and classes simply
frequently used?Q.3 What threshold value is good for filtering?
Process Measure class universality of classes in application collection Investigate the result to answer the questions
The top-20 classes in the universality [Q.1] Difference between the universality and the fan-in [Q.2] Distribution of the universality [Q.3]
Target 39 application packages (131,328 classes)
Java SE 1.5 Various OSS packages covering a broad range of domains
– Eclipse (IDE), Azureus (Network client), Apache Tomcat (Network server), Freemind (Drawing tool), …
2008/12/2 AOAsia 4 13
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 1 –Top 20 classes in the class universality
Q.1 What kind of classes have high universality?
Fundamental / Utility classes
2008/12/2 AOAsia 4 14
Class name Univ. CFI
1 java.lang.String 0.933 69,324
2 java.lang.Object 0.915 55,628
3 java.util.List 0.793 12,9814 java.lang.System 0.780 11,191
5 java.lang.Class 0.776 10,590
6 java.lang.Throwable 0.775 10,467
7 java.util.Iterator 0.773 10,191
8 java.util.ArrayList 0.772 10,135
9 java.lang.Exception 0.761 8,840
10 java.util.Map 0.757 8,47611 java.lang.Integer 0.748 7,568
12 java.util.Set 0.741 6,954
13 java.io.File 0.736 6,554
14 java.lang.StringBuffer 0.735 6,907
15 java.io.PrintStream 0.730 6,132
16 java.util.HashMap 0.730 6,129
17 java.io.IOException 0.725 6,115
18 java.util.Collection 0.724 5,690
19 java.lang.IllegalArgumentException
0.714 5,057
20 java.lang.Runnable 0.699 6,790
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 1 –Universality and fan-in
High universality / Low fan-in Classes with fundamental /
utility role
Low universality / High fan-in Classes implementing
crosscutting concerns in a large application
Q.2 Can universality distinguish classes widely used and classes simply frequently used?
2008/12/2 AOAsia 4 15
Class NameRank
[Univ.]Rank [CFI]
java.lang.Character 39 104
java.util.LinkedList 41 105
java.io.FileOutputStream 56 177
java.lang.Comparable 78 240
java.util.Stack 95 354
Class NameRank
[Univ.]Rank [CFI]
org.eclipse.swt...Control
213 25
org.eclipse.swt.SWT 221 34
org.eclipse.core…IResource
564 69
org.openide.util.NbBundle
1,398 24
org.openide.ErrorManager 1,496 54
High universality / Low fan-in
Low universality / High fan-in
Yes.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 1 –Distribution 1.0-0.5: general-purpose classes
Primitive/fundamental classes, collection utilities, … 0.5-0.2: domain-specific classes
Logging utility, networking, GUI, … 0.2-0: application-local classes
2008/12/2 AOAsia 4 16
Univ. #of Classes Package
1.0 – 0.9 2 java.lang
0.9 – 0.8 0 -
0.8 – 0.7 17 java.util, java.lang, java.io
0.7 – 0.6 18 java.lang, java.util, java.io, java.net, java.awt
0.6 – 0.5 49 java.util, java.lang, java.io, javax.swing, java.awt,...
0.5 – 0.4 80 java.io, java.lang, javax.swing, javax.swing, java.awt,...
0.4 – 0.3 196 org.eclipse.swt.widgets, javax.swing, java.util, java.awt.event, java.lang, ...
0.3 – 0.2 348 org.eclipse.swt.widgets, org.eclipse.swt.graphics, javax.swing, javax.management, java.awt, ...
0.2 – 0.1 1,385 org.eclipse.swt.widgets, org.eclipse.swt.dnd, javax.management,org.gudy.azureus2.core3.util, org.bouncycastle.asn1, ...
0.1 – 0.0 129,233 soot.jimple.parser.node, org.apache.poi.....functions, test, soot.coffi, ...
Q.3 What threshold value is good for filtering?0.2 for finding application-specific concerns0.5 for filtering out generic concerns
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 2 – Overview Question
Can the pattern universality distinguish among generic, domain-specific and application-specific patterns?
Process Categorize coding patterns according to pattern universality
1.0 – 0.5: Generic pattern 0.5 – 0.2: Domain-specific pattern 0.2 – 0.0: Application-specific pattern
Target Coding patterns
Azureus (presented in [Ishio, 2008]) Application collection
Same as Case Study 12008/12/2 AOAsia 4 17
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Case Study 2 – Result Generic patterns (2290 patterns)
String manipulation String.lastIndexOf() / IF / String.substring() / END_IF
Collection manipulation List.get() / IF / List.remove() / END_IF
Domain-specific patterns (79 patterns) Collection manipulation
Map.size() / Iterator.remove() / LinkedHashMap.get() / LinkedHashMap.remove()
Domain-specific?
Application-specific patterns (2293 patterns) Logging
LOOP / Thread.sleep() / Debug.printStackTrace() / END_LOOP Synchronization
IF / AEMonitor.enter() / ArrayList.remove() / AEMonitor.exit() / END_IF
2008/12/2 AOAsia 4 18
Q. Can the pattern universality distinguish generic / domain-specific / application-specific patterns?Almost yes.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Discussion Universality metric can distinguish universally-used
classes Resource management classes in Eclipse/NetBeans are
distinguished as application-specific although they have large fan-in
Universality metric value may depend on a set of applications
Case studies in different target are needed E.g. industrial software systems.
2008/12/2 AOAsia 4 19
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Discussion Some domain-specific classes
have higher class universality than general-purpose classes
- Ideas to improve the metric Propagate fan-in through
important use-relation E.g. inheritance
Combining other metric
+Less popular generic concerns may be more interesting than famous domain-specific ones
2008/12/2 AOAsia 4 20
Class name Univ.
…
33 java.awt.Component 0.63
…
113 java.util.ListIterator 0.46
…
230 java.util.LinkedHashMap
0.36
…
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Summary and future works Cross-application fan-in analysis for filtering coding
patterns Measures universality, or a metric that represents how
widely a class/pattern is used
Future work Case studies with different applications Refinement of the universality metric
2008/12/2 AOAsia 4 21
top related