SlideServe
Menu
Préférences
© SlideServe · v2026

Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining

andersonmelissa avatar
13 diapositives · 166 Views · Jan 02, 2020

Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining. Tatsuya Miyake Takashi Ishio Katsuro Inoue. copy- and- paste. while (iter.hasNext()) { Item item = (Item)iter.next(); buf.append(item.toString()); }. while (iter.hasNext()) {

Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining - slide 1
01 / 13Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining
1 / 17

Télécharger la présentation

Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Towards Maintenance Support for Idiom-based Code Using Sequential Pattern Mining Tatsuya Miyake Takashi Ishio Katsuro Inoue

  2. copy- and- paste while (iter.hasNext()) { Item item = (Item)iter.next(); buf.append(item.toString()); } while (iter.hasNext()) { Item item = (Item)iter.next(); buf.append(item.toString()); } code2 code1 reuse the idiom while (iter.hasNext()) { Datadata = (Data)iter.next(); buf.append(process(data)); buf.append(data.toString()); } code3 Code derived from an idiom • An idiom is a code fragment to implement a particular kind of concern. AOASIA3

  3. copy- and- paste while (iter.hasNext()) { Item item = (Item)iter.next(); buf.append(item.toString()); } while (iter.hasNext()) { Item item = (Item)iter.next(); buf.append(item.toString()); } code2 code1 reuse the idiom while (iter.hasNext()) { Datadata = (Data)iter.next(); buf.append(process(data)); buf.append(data.toString()); } code3 A defect crosscutting modules • A company reuses many idioms in a software. • An idiom often spread across several systems. • When a defect is found in an idiom, developers have to inspect all instances of the idiom. • A similar problem is well-known in code-clone research, but code clone does not cover idioms. AOASIA3

  4. Our research goal • To detect all instances of an idiom, we are planning to combine three approaches: Pattern Mining: sequential patterns Idiom-based Code Aspect Mining: crosscutting concern code Code Clone Detection: copy-and-pasted code AOASIA3

  5. A B C ×3 E B C ×2 D F C ×2 Sequential Pattern Mining sequence database • Sequential pattern mining extracts frequent subsequences from a sequence database. • We apply prefixspan to a sequence database extracted from Java software. A B C D E A E B C A E D F B C A D B F C Sequential pattern AOASIA3

  6. Sample.hoge() A.foo() IF A.bar() END-IF Sequence Database Extraction from Java Software • Sequence element of java source code • Method call element • IF/ELSE/END-IF element • LOOP/END-LOOP element • A sequence is extracted from a java method void sample () { hoge (); i =a.foo(); if( i == 0 ) { k = i; a.bar(); } } Sequence Element of Sequence AOASIA3

  7. Preliminary Case Study • We applied sequential pattern mining to Java source code to detect idiom-based code. • The target software is JHotDraw • We inspected whether the instances of a pattern contribute to a single concern or not. AOASIA3

  8. Application Specific Patterns org.jhotdraw.standard. DuplicateCommand public void execute() { super.execute(); setUndoActivity(createUndoActivity()); FigureSelection selection = view().getFigureSele・・・ // create duplicate figure(s) FigureEnumeration figures = (FigureEnumeration) ・・ getUndoActivity().setAffectedFigures(figures); view().clearSelection();   ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ } • Example of an idiom for undo • Extracted from many classes, the pattern might be related to a crosscutting concern setUndoActivity() createUndoActivity() getUndoActivityI() setAffectedFigures() org.jhotdraw. standard.ResizeHandle public void invokeStart(int x, int y, DrawingView view) { setUndoActivity(createUndoActivity(view)); getUndoActivity().setAffectedFigures(new Sing ・・ ((ResizeHandle.UndoActivity)getUndoActivity()).se・・ } AOASIA3

  9. Patterns of Implementation Idioms org.jhotdraw.standard.StandardDrawingView public void addAll(Collection figures) { FigureEnumeration fe = new FigureEnumerato・・・ while (fe.hasNextFigure()) { add(fe.nextFigure()); } } • Not application specific pattern • In aspect mining, this kind of pattern is not interested. • Maybe useful for developers inspecting idiom Sequential Pattern ( Iteration ) FigureEnumeration.hasNextFigure() while FigureEnumeration.nextFigure() } org.jhotdraw.standard.CompositeFigure public FigureEnumeration figures(Rectangle ・・・ if (_theQuadTree != null) {    ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ while (fe.hasNextFigure()) { Figure f = fe.nextFigure(); //int z = fFigures.indexOf(f); l2.add(new OrderedFigureElement(f, ・・ } ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ } AOASIA3

  10. The Difference from Code Clone Detection Tool The patterns extracted by Sequential pattern mining tool org.jhotdraw.standard.CutCommand public void execute() { super.execute(); setUndoActivity(createUndoActivity()); FigureEnumeration fe = view().selection(); List affected = CollectionsFactory.current().createL・・・ Figure f; FigureEnumeration dfe; while (fe.hasNextFigure()) { f = fe.nextFigure(); affected.add(0, f); dfe = f.getDependendFigures();     ・・・・・・・・・・・・・・・・・・・・・ } fe = new FigureEnumerator(affected); getUndoActivity().setAffectedFigures(fe); UndoActivity ua = (UndoActivity) getUndoActivity(); ua.setSelectedFigures(view().selection()); copyFigures(ua.getSelectedFigures(), ua.getSele・・・・ deleteFigures(getUndoActivity().getAffectedFigures()); view().checkDamage(); } The code extracted by code clone detection tool org.jhotdraw.fiures.GroupCommand public void execute() { super.execute(); setUndoActivity(createUndoActivity()); getUndoActivity().setAffectedFigures(view().selection()); ((GroupCommand.UndoActivity)getUndoActivity()).group・・・ view().checkDamage(); } org.jhotdraw.standard.AlignCommand public void execute() { super.execute(); setUndoActivity(createUndoActivity()); getUndoActivity().setAffectedFigures(view().selection()); ((AlignCommand.UndoActivity)getUndoActivity()).alignA・・・ view().checkDamage(); } AOASIA3

  11. Summary • Sequential pattern mining found idiom-based code • Crosscutting concern • Implementation Idiom • Not application-specific patterns • Useful information for software maintenance • Combining with code clone detection is valuable • The result of sequential pattern mining is different from the result of code clone detection • We need further case studies on other software systems AOASIA3

  12. Future Direction • Combining this approach and code clone analysis • detecting all code fragments derived from an original idiom • Support for inspecting idiom-based code crosscutting modules. • Aspect mining based on sequential pattern mining • Sequential pattern mining capture an idiom that is crosscutting modules and interleaving with other code fragments • Distinguishing a crosscutting concern from implementation idioms AOASIA3

  13. AOASIA3