Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cross-application.

Similar presentations


Presentation on theme: "Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cross-application."— Presentation transcript:

1 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 Ichii Takashi Ishio Katsuro Inoue Osaka University 1 AOAsia 4 2008/12/2

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

3 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() IF getMessage() debug() END_IF … getStatus() isDebugEnabled() IF debug() END_IF … isDebugEnabled() IF debug() END_IF … 1: isDebugEnabled() 2: IF 3: debug() 4: END_IF Source codeMethod call sequenceCoding pattern parse & normalize Sequential pattern mining

4 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: IF 3: debug() 4: END_IF 1: iterator() 2: hasNext() 3: LOOP 4: next() 5: hasNext() 6: END_LOOP Logging Target applicationDetected patterns Iterator idiom

5 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: LOOP 4: next() 5: hasNext() 6: END_LOOP 1: isDebugEnabled() 2: IF 3: debug() 4: END_IF Logging Iterator idiom Appears in only two applications Appears in almost all applications

6 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: LOOP 4: next() 5: hasNext() 6: END_LOOP 1: isDebugEnabled() 2: IF 3: debug() 4: END_IF 1: activate 2: IF 3: deactivate 4: END_IF 1: indexOf 2: lastIndexOf 3: substring 1: contains 2: IF 3: get 4: END_IF 1: iterator() 2: hasNext() 3: LOOP 4: next() 5: hasNext() 6: END_LOOP 1: isDebugEnabled() 2: IF 3: debug() 4: END_IF 1: activate 2: IF 3: deactivate 4: END_IF 1: indexOf 2: lastIndexOf 3: substring 1: contains 2: IF 3: get 4: END_IF Target application Application collectionUse-relation between classesList of universally-used classes Detected patternsFiltered patterns

7 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 codeUse-relation graph Warehouse Liquor WarehouseApp class Liquor { long price; String name; … } class Warehouse { … Liquor liq = new Liquor(); … }

8 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

9 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 AppClassCFIAFI WAWarehouse 00 Liquor 32 SAStore 00 Shelf 11 Liquor 32 Paper 21

10 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 AppClassCFIAFI WAWarehouse 00 Liquor 32 SAStore 00 Shelf 11 Liquor (copy)32 Paper 21 Univ. 0 1.2 0 0.39 1.2 0.61 Frequently-used universally Frequently- used locally i c : class fan-in of c ; a c : application fan-in of c ; | C | : total number of classes; | A | : total number of applications

11 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 ClassUniv. Collection 0.72 Iterator 0.77 Involved classes 1: iterator() 2: hasNext() 3: LOOP 4: next() 5: hasNext() 6: END_LOOP Pattern universality = 0.72

12 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Case studies Case 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

13 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Case Study 1 – Overview Questions 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

14 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 nameUniv.CFI 1 java.lang.String 0.93369,324 2 java.lang.Object 0.91555,628 3 java.util.List 0.79312,981 4 java.lang.System 0.78011,191 5 java.lang.Class 0.77610,590 6 java.lang.Throwable 0.77510,467 7 java.util.Iterator 0.77310,191 8 java.util.ArrayList 0.77210,135 9 java.lang.Exception 0.7618,840 10 java.util.Map 0.7578,476 11 java.lang.Integer 0.7487,568 12 java.util.Set 0.7416,954 13 java.io.File 0.7366,554 14 java.lang.StringBuffer 0.7356,907 15 java.io.PrintStream 0.7306,132 16 java.util.HashMap 0.7306,129 17 java.io.IOException 0.7256,115 18 java.util.Collection 0.7245,690 19 java.lang.IllegalArgumentException 0.7145,057 20 java.lang.Runnable 0.6996,790

15 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 Name Rank [Univ.] Rank [CFI] java.lang.Character 39104 java.util.LinkedList 41105 java.io.FileOutputStream 56177 java.lang.Comparable 78240 java.util.Stack 95354 Class Name Rank [Univ.] Rank [CFI] org.eclipse.swt...Control 21325 org.eclipse.swt.SWT 22134 org.eclipse.core…IResource 56469 org.openide.util.NbBundle 1,39824 org.openide.ErrorManager 1,49654 High universality / Low fan-in Low universality / High fan-in  Yes.

16 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 ClassesPackage 1.0 – 0.92 java.lang 0.9 – 0.80 - 0.8 – 0.717 java.util, java.lang, java.io 0.7 – 0.618 java.lang, java.util, java.io, java.net, java.awt 0.6 – 0.549 java.util, java.lang, java.io, javax.swing, java.awt,... 0.5 – 0.480 java.io, java.lang, javax.swing, javax.swing, java.awt,... 0.4 – 0.3196 org.eclipse.swt.widgets, javax.swing, java.util, java.awt.event, java.lang,... 0.3 – 0.2348 org.eclipse.swt.widgets, org.eclipse.swt.graphics, javax.swing, javax.management, java.awt,... 0.2 – 0.11,385 org.eclipse.swt.widgets, org.eclipse.swt.dnd, javax.management, org.gudy.azureus2.core3.util, org.bouncycastle.asn1,... 0.1 – 0.0129,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 concerns  0.5 for filtering out generic concerns

17 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 1 2008/12/2 AOAsia 4 17

18 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.

19 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

20 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 nameUniv. … 33 java.awt.Component 0.63 … 113 java.util.ListIterator 0.46 … 230 java.util.LinkedHashMap 0.36 …

21 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


Download ppt "Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cross-application."

Similar presentations


Ads by Google