Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Refactoring Edit History of Source Code

15.093 visualizaciones

Publicado el

Presented at ICSM 2012
http://dx.doi.org/10.1109/ICSM.2012.6405336

Publicado en: Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Refactoring Edit History of Source Code

  1. 1. Refactoring Edit History of Source Code Shinpei Hayashi† Takayuki Omori‡ Teruyoshi Zenmyo† Katsuhisa Maruyama‡ Motoshi Saeki† † Tokyo Institute of Technology, Japan ‡ Ritsumeikan University, Japan
  2. 2. Background l  Edit histories are used for various ways –  Committing edits into SCM repository –  Undo/redo past edit operations –  Understanding histories by replaying them [Hattori 10][Omori 11] à Well-structured history enhances these activities The recorded raw history: ... actually well-structured? 2
  3. 3. Example private  int  foo()  {   private  int  transit()  {          int  state  =  ...;          int  state  =  ...;                    log.trace(”state  =  ”  +  state);          ...          ...          state  =  bar(state,  false);          state  =  nextState(state  +  1,  true);                    log.trace(”state  =  ”  +  state);          ...                                                                    ...                                                            }   }      private  int  bar(int  state,  boolean  f)  {   private  int  nextState(int  state,  boolean  f)  {          ...        ... Adding Bug-fix (1) Rename bar   Adding Rename Bug-fix (3) log.trace (1) false to true to nextState log.trace  (2) foo to transit state to state  +  1 Several problems –  Tangled changes according to multiple tasks –  2nd code refactoring w/o tool causes individual changes –  Loggings are hard to undo 3
  4. 4. Edit History Refactoring Code refactoring History refactoring Refactor Refactor Source code Source code Edit history Edit history l  Definition –  Restructuring of an edit history for improving the usability and/or understandability of the history without changing its overall effect 4
  5. 5. Edit History Refactoring Adding Bug-fix (1) Rename bar   Adding Rename Bug-fix (3)log.trace (1) false to true to nextState log.trace  (2) foo to transit state to state  +  1 Refactor! l  Changes are reordered by the associated tasks for easily committing them separately l  Code refactorings and loggings: merged into a single change for easily handling them –  Make the loggings latest for easily undoing them 5
  6. 6. Changes l  Change := (sequence of chunks, group) –  A sequence of keystrokes on IDE generates a change including a single chunk foo trans it foo sit foo sit tran tran Edit history removal addition replace replace –  A code refactoring w/ tool generates a large change including multiple chunks foo sit tran foo sit tran foo sit multiple Edit history tran replaces 6
  7. 7. Primitive Refactorings Swap Changes Merge Changes Cancel Changes Split Change l  Transformation procedures and pre/post-conditions are defined 7
  8. 8. Large Refactorings Reorder Changesl  Bubble sorting based on a group order –  Applying Swap Changes multiple times Swap Swap Swap Merge Merge Merge 8
  9. 9. Large Refactorings Reconfigure Changesl  Localizing a large change –  e.g., file-level formatting à method level formatting Some edits Formatting Split (by methods) Merge Revert 9
  10. 10. Historef: A supporting tool 10
  11. 11. Historef: A supporting tool Performed changes 11
  12. 12. Historef: A supporting tool Groups / Switching UI 12
  13. 13. Historef: A supporting tool History refactoring commands 13
  14. 14. Application 1: Task Level Commit l  Commit the changes to SCM repository separately for each task –  Reorder the changes based on groups –  Merge the reordered changes, and commit them to SCM Reorder Merge Merge Merge Commit 14
  15. 15. Application 2: Selective Undo l  Undoing the focused change from history –  Swap to make the focused changes latest –  Merge them, and undo the latest change Merge Undo 15
  16. 16. Example! Edit History Refactoring!private(int(foo()({( private(int(transit()({(((((int(state(=(...;( ((((int(state(=(...;((((((((((...( ((((log.trace(”state(=(”(+(state);( ((((...( Code refactoring! History refactoring!((((state(=(bar(state,(false);( ((((state(=(nextState(state(+(1,(true);( Refactor! Refactor!((((( ((((log.trace(”state(=(”(+(state);(((((...(((((((((((((((((((((((((((((( ((((...((((((((((((((((((((((((((((((}( }( Source code! Source code! Edit history! Edit history!( (private(int(bar(int(state,(boolean(f)({( private(int(nextState(int(state,(boolean(f)({(((((...! ((((...! Adding Bug-fix (1) Rename bar( Adding Rename foo to transit! Bug-fix (3) !  Definition! log.trace (1)! false to true! to nextState! log.trace((2)! state to state(+(1! –  Restructuring of an edit history for improving the usability and/or understandability of the history Several problems! without changing its overall effect! –  Tangled changes according to multiple tasks! –  2nd code refactoring w/o tool causes individual changes! –  Loggings are hard to undo! 3! 4! Primitive Refactorings! Application 1: Task Level Commit! Swap Changes! Merge Changes! !  Commit the changes to SCM repository separately for each task! –  Reorder the changes based on groups! –  Merge the reordered changes, and commit them to SCM! Cancel Changes! Split Change! Reorder! Merge! Merge! Merge! !  Transformation procedures and pre/post-conditions are defined! 7! Conclusion Commit! 14!
  17. 17. Credit l  Photo by Elsie esq. –  Chronology | Flickr –  http://www.flickr.com/photos/elsie/4607687530/ 17

×