with search based recommendation
play

with Search-Based Recommendation 1 Motivation Architectural - PowerPoint PPT Presentation

Interactive and Guided Architectural Refactoring with Search-Based Recommendation 1 Motivation Architectural refactoring for solving technical debts An ideal design in mind A solution consisting of lots of low-level refactorings


  1. Interactive and Guided Architectural Refactoring with Search-Based Recommendation 1

  2. Motivation • Architectural refactoring for solving technical debts – An ideal design in mind – A solution consisting of lots of low-level refactorings  Industrial architectural refactoring involves over 800 low-level refactoring steps [Tokuda & Batory , ASE’99]. • Existing Approaches: fully automatic (optimize metrics) – Metrics can hardly represent the design in mind – Users never in control 2

  3. Our solution: Refactoring Navigator 3

  4. Our solution: Refactoring Navigator • Input: – Source: Current code implementation – Destination: A user-specified intended design • Output: – A sequence of refactoring steps, developers can accept or reject • Give control back to the user: – User provides target design – Use human feedback to improve recommendation 4

  5. Motivating Example: A Bus Monitor System • Main features: – Receives dynamic bus operational information; – Show the operational information on GUI; – Update the bus operational information on different views in real time. 5

  6. Source: the code implementation Prob oblem m 2: 2: God Class CurveView Problem m 1: 1: BusMonitor TableView Inconv conveni enient ent Extensio xtension MapView 6

  7. Destination: desired design Monitor GUI Bus Data Concrete View Abstract View 7

  8. source refactoring ring path destination ination Monitor GUI Bus Data CurveView BusMonitor TableView Concrete View Abstract View MapView user r feedback ck 8

  9. source refactoring ring path destination ination Monitor GUI Bus Data CurveView BusMonitor TableView Concrete View Abstract View MapView user r feedback ck 9

  10. Gap between Source and Destination Monitor GUI Bus Data BusMonitor ` Concrete View Abstract View MapView TableView CurveView 10 10

  11. Step 1: move updateMapView() from BusMonitor to MapView Monitor GUI Bus Data BusMonitor updateMapView (…) ` Concrete View Abstract View MapView TableView CurveView 11 11

  12. Step 2: move updateTableView() from BusMonitor to TableView Monitor GUI Bus Data updateTableView (…) BusMonitor ` Concrete View Abstract View MapView TableView CurveView 12 12

  13. Step 3: pull up update*View() from *View to a new abstract view; move it to Abstract View Monitor GUI Bus Data updateCurveView (…) BusMonitor User rejected ` Concrete View Abstract View MapView TableView CurveView AbstractView updateView (…) updateMapView (…) updateTableView (…) 13 13

  14. Refactoring Navigator suggests another path… 14 14

  15. New Step 3: move updateCurveView() from BusMonitor to CurveView Monitor GUI Bus Data updateCurveView (…) BusMonitor ` Concrete View Abstract View MapView TableView CurveView 15 15

  16. Step 4: pull up update*View() from *View to a new abstract view; move it to Abstract View Monitor GUI Bus Data BusMonitor Concrete View Abstract View MapView TableView CurveView AbstractView updateView (…) updateMapView (…) updateTableView (…) updateCurveView (…) 16 16

  17. Step 5: extract a BusData class; move it to Bus Data module Monitor GUI Bus Data BusData BusMonitor Concrete View Abstract View MapView TableView CurveView AbstractView 17 17

  18. Approach 1.Target Design Target Construction Model 3.Reflexion Model Reflexion Generation Model Source 2.Source Model Source Code Extraction Model 4.Refactoring Recommendations Path Calculation 5.User Examination User 6.Recommended Accepted Feedback Recommendations Step Execution 18 18

  19. Approach Key Step teps 1.Target Design Target Construction Model 3.Reflexion Model Reflexion Generation Model Source 2.Source Model Source Code Extraction Model 4.Refactoring Recommendations Path Calculation 5.User Examination User 6.Recommended Accepted Feedback Recommendations Step Execution 19 19

  20. Approach 1.Target Design Target Construction Model 3.Reflexion Model Reflexion Generation Model Source 2.Source Model Source Code Extraction Model 4.Refactoring Recommendations Path Calculation 5.User Examination User Accepted 6.Recommended Feedback Step Execution Recommendations 20 20

  21. Reflexion Model Generation • A reflexion model: Monitor GUI Bus Data – Source Model BusMonitor – Target Model – Mapping from source ` model to target model Concrete View Abstract View MapView TableView CurveView 21 21

  22. Mapping Source Model to Target Design Monitor GUI Bus Data CurveView BusMonitor TableView Concrete View Abstract View MapView 22 22

  23. Design-Implementation Difference Representation in Reflexion Model Conforma rmance nce Monitor GUI Bus Data BusMonitor BusData Divergenc ence Absence ce Concrete View Abstract View MapView TableView CurveView 23 23

  24. Approach Overview 1.Target Design Target Construction Model 3.Reflexion Model Reflexion Generation Model Source 2.Source Model Source Code Extraction Model 4.Refactoring Recommendations Path Calculation 5.User Examination User Accepted 6.Recommended Feedback Step Execution Recommendations 24 24

  25. Refactoring Path Calculation • Aim: – Improve the conformance of reflexion model • A search-based method – Try various refactoring operations on source model to find the solution. Monitor GUI Bus Data Monitor GUI Bus Data BusData BusMonitor BusMonitor ` Concrete View Abstract View Concrete View Abstract View MapView TableView CurveView MapView TableView CurveView AbstractView 25 25

  26. Refactoring Path Calculation • Define basic refactoring operations to transform reflexion model. • Quantify the conformance of a reflexion model. • Search algorithm w.r.t user feedback. 26 26

  27. Basic Refactorings • Move method – Move a method from one class to another • Pull up field/method – Extract and move similar fields/methods from multiple classes to their super class or interface. • Extract class (Tsantalis, N. and A. Chatzigeorgiou , JSS’11) – Decompose a large class into smaller classes with higher cohesion 27 27

  28. Quantify reflexion model conformance The e set of c code • Metrics for a reflexion model, model relation tion supporting ting a – Inconsistency dive vergenc ence edge edge The e set of a absence ce 𝑶 𝒕𝒖𝒔 = 𝑩𝒄𝒕 𝒏𝒑𝒆𝒇𝒎 + ෍ |𝑻𝒔𝒅(𝒆)| edge in The e set of dive vergence ence 𝒆∈𝑬𝒋𝒘(𝒏𝒑𝒆𝒇𝒎) edge in A A Suppose e X invokes es X X Z metho hods ds in Y 3 time mes, s, Z contr tribut ibute e 1 acces ess s fields s in Y 5 times, es, con ontr tribut ibute e 3+5=8 +5=8 B B Y 28 28

  29. Quantify reflexion model conformance • Metrics for a reflexion model, model – Inconsistency 𝑶 𝒕𝒖𝒔 = 𝑩𝒄𝒕 𝒏𝒑𝒆𝒇𝒎 + ෍ |𝑻𝒔𝒅(𝒆)| 𝒆∈𝑬𝒋𝒘(𝒏𝒑𝒆𝒇𝒎) – Lexical conformance  Average lexical similarity 𝑻𝒋𝒏 𝒎𝒇𝒚_𝒃𝒘𝒉 ∈ [𝟏, 𝟐) – Design quality metrics  Cohesion and coupling metrics 𝑬𝑹 𝒃𝒘𝒉 ∈ [𝟏, 𝟐) • Overall metrics: 𝑮 𝒔𝒇𝒈 = −𝑶 𝒕𝒖𝒔 − 𝑬𝑹 𝒃𝒘𝒉 − 𝑻𝒋𝒏 𝒎𝒇𝒚_𝒃𝒘𝒉 29 29

  30. Incorporating User Feedback • User feedback – Reject refactorings – Accept refactorings • Rationale – Refactorings similar to rejected refactorings should get penalty, while those similar to accepted refactoring should get reward. 30 30

  31. User feedback incorporation • Basic fitness for a refactoring (i.e., reflexion model transformed by this refactoring) is: 𝑮 𝒔𝒇𝒈 = −𝑶 𝒕𝒖𝒔 − 𝑬𝑹 𝒃𝒘𝒉 − 𝑻𝒋𝒏 𝒎𝒇𝒚_𝒃𝒘𝒉 • If the refactoring is similar to m accepted refactoring and n rejected refactoring, then 𝑭𝒘𝒃 𝒔𝒇𝒈 = 𝑮 𝒔𝒇𝒈 × (𝟐 − 𝜷) 𝒏 × (𝟐 + 𝜸) 𝒐 Reward ra rate te Penalty alty ra rate 31 31

  32. Search algorithm w.r.t user feedback • Hill-climbing algorithm Detect ect all basic c refactor orin ing opportunit unities ies in the e source ce model Neig ighb hbors s (result ulted d Curr rrent nt reflexion xion model reflexion xion models by applyin ing refactori rings) 32 32

  33. Search algorithm w.r.t user feedback • Hill-climbing algorithm Best t neighb hbori oring ng reflexion xion model (with th highest hest conformance) rmance) Curr rrent nt reflexion xion model 33 33

  34. Search algorithm w.r.t user feedback • Hill-climbing algorithm (sub)optima ptimal l reflexion xion model Escape Local l optima ma 34 34

  35. Search algorithm incorporating user feedback • Hill-climbing algorithm A r refactoring ring solut utio ion n consists sists of a a n numb mber er of refactoring ring step teps 35 35

  36. Tool: Refactoring Navigator 36 36

  37. Empirical Evaluation 37 37

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend