Your SlideShare is downloading. ×
Diagnosis and semi-automatic correction of detected design inconsistencies in source code
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Diagnosis and semi-automatic correction of detected design inconsistencies in source code

337
views

Published on

Diagnosis and semi-automatic correction of detected design inconsistencies in source code by Sergio Castro, Johan Brichau and Kim Mens, ESUG09, Brest, France

Diagnosis and semi-automatic correction of detected design inconsistencies in source code by Sergio Castro, Johan Brichau and Kim Mens, ESUG09, Brest, France

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
337
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Diagnosis and semi-automatic correction of detected design inconsistencies in source code Sergio Castro RELEASeD lab Université catholique de Louvain sergio.castro@uclouvain.be Advisor: Kim Mens 1 Monday 31 August 2009 1
  • 2. An inconsistency example AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable ^true. ^aBlock value. 2 Monday 31 August 2009 2
  • 3. An inconsistency example The command design pattern AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable ^true. ^aBlock value. 2 Monday 31 August 2009 2
  • 4. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable ^true. ^aBlock value. 2 Monday 31 August 2009 2
  • 5. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable ^true. ^aBlock value. 2 Monday 31 August 2009 2
  • 6. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable - isUndoable ^true. ^aBlock value. ^true. 2 Monday 31 August 2009 2
  • 7. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable - isUndoable ^true. - undoAction ^aBlock value. ^true. 2 Monday 31 August 2009 2
  • 8. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true AbstractAction - (abstract) perform - isUndoable ^false. Dummy Experimental DrawAction QueryAction Action Action - perform ? - perform - perform - perform - undoAction - isUndoable - undoAction - undoAction - isUndoable ^true. - isUndoable - isUndoable ^true. - undoAction ^aBlock value. ^true. 2 Monday 31 August 2009 2
  • 9. An inconsistency example The command design pattern Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true User-defined consistency 3 Monday 31 August 2009 3
  • 10. Inconsistency management activities Correcting Diagnosing Inconsistency detection Such as Lint, CheckStyle, etc Many tools offering support for Predefined management of predefined consistency consistencies. definitions 4 Monday 31 August 2009 4
  • 11. Inconsistency management activities Correcting Diagnosing Inconsistency detection We propose a general User-defined approach for the management of consistency user-defined consistencies. definitions 5 Monday 31 August 2009 5
  • 12. Inconsistency management activities Explaining } Correcting abnormal observations and Corrective suggesting corrective actions framework Already used for inconsistency management in other areas of SE (e.g., requirements engineering, UML Diagnosing modelling, data bases) Defining and verifying } Inconsistency consistency rules detection IntensiVE User-defined consistency definitions 6 Monday 31 August 2009 6
  • 13. Inconsistency management activities Explaining } Correcting abnormal observations and Corrective suggesting corrective actions framework Already used for inconsistency management in other areas of SE (e.g., requirements engineering, UML Diagnosing modelling, data bases) Defining and verifying } Inconsistency consistency rules detection IntensiVE User-defined consistency definitions ( http://www.intensive.be ) 6 Monday 31 August 2009 6
  • 14. IntensiVE ( http://www.intensive.be ) Inconsistency detection User-defined consistency definitions 7 Monday 31 August 2009 7
  • 15. Defining and verifying constraints using IntensiVE • Many kind of checks. • Defined as relationships among sets of source code elements. • Sets are intensionally defined and with queries over source code referred as Intensional Views. 8 Monday 31 August 2009 8
  • 16. Verification of the Undoable Actions constraint Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with View with classes returning classes true in the implementing the isUndoable undoAction method method 9 Monday 31 August 2009 9
  • 17. Verification of the Undoable Actions QUERY: constraint classChainReallyUnderstandsMethodWith Name(?class,?method,isUndoable), methodReturnsBoolean(?method,[true]) Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with View with classes returning classes true in the implementing the isUndoable undoAction method method 9 Monday 31 August 2009 9
  • 18. Verification of the Undoable Actions QUERY: constraint classChainReallyUnderstandsMethodWith QUERY: classChainReallyUnderstandsMethodWith Name(?class,?method,isUndoable), Name(?class,?,undoAction) methodReturnsBoolean(?method,[true]) Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with View with classes returning classes true in the implementing the isUndoable undoAction method method 9 Monday 31 August 2009 9
  • 19. Verification of the Undoable Actions QUERY: constraint classChainReallyUnderstandsMethodWith QUERY: classChainReallyUnderstandsMethodWith Name(?class,?method,isUndoable), Name(?class,?,undoAction) methodReturnsBoolean(?method,[true]) Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with View with classes returning classes true in the If consistent, any class in the implementing the isUndoable first view should be also in the undoAction method second, and vice versa method 9 Monday 31 August 2009 9
  • 20. Verification of alternative views QUERY: QUERY: classChainReallyUnderstandsMethodWith classChainReallyUnderstandsMethodWith Name(?class,?method,isUndoable), Name(?class,?,undoAction) methodReturnsBoolean(?method,[true]) Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with classes View with classes returning true in the implementing the isUndoable method undoAction method AbstractAddAction AbstractAddAction AddClassificationAction AddClassificationAction ExperimentalAction 10 Monday 31 August 2009 10
  • 21. Verification of alternative views QUERY: QUERY: classChainReallyUnderstandsMethodWith classChainReallyUnderstandsMethodWith Name(?class,?method,isUndoable), Name(?class,?,undoAction) methodReturnsBoolean(?method,[true]) Consistency property: ! Action, an undoAction method should be provided the isUndoable method returns true View with classes View with classes returning true in the implementing the isUndoable method undoAction method AbstractAddAction AbstractAddAction AddClassificationAction AddClassificationAction ExperimentalAction ? 10 Monday 31 August 2009 10
  • 22. IntensiVE (consistency checking) 11 Monday 31 August 2009 11
  • 23. IntensiVE (consistency checking) Classes that return true in the isUndoable method { 11 Monday 31 August 2009 11
  • 24. IntensiVE (consistency checking) Classes that Classes that return true in the implement the isUndoable method undoAction method { 11 { Monday 31 August 2009 11
  • 25. IntensiVE (consistency checking) This class does But implements an not return true at the undoAction method isUndoable method 12 Monday 31 August 2009 12
  • 26. IntensiVE (consistency checking) ExperimentalAction This class does But implements an not return true at the undoAction method isUndoable method 12 Monday 31 August 2009 12
  • 27. IntensiVE (diagnosing inconsistencies) ExperimentalAction Why OR: Why ExperimentalAction is ExperimentalAction is a not a result of the query result of the query defining defining this set? this set? 13 Monday 31 August 2009 13
  • 28. Inconsistency management activities Explaining } Correcting abnormal observations and Corrective suggesting corrective actions framework Already used for inconsistency management in other areas of SE (e.g., requirements engineering, UML Diagnosing modelling, data bases) Defining and verifying } Inconsistency consistency rules detection IntensiVE User-defined consistency definitions ( http://www.intensive.be ) 14 Monday 31 August 2009 14
  • 29. Correcting Diagnosing Corrective framework 15 Monday 31 August 2009 15
  • 30. What is diagnosis? Generating hypotheses explaining Abductive abnormal reasoning observations 16 Monday 31 August 2009 16
  • 31. What is diagnosis? Generating hypotheses explaining Abductive abnormal reasoning observations 16 Monday 31 August 2009 16
  • 32. What is diagnosis? Generating hypotheses explaining Abductive abnormal reasoning observations one of the fundamental forms of human reasoning 16 according to Pierce Monday 31 August 2009 16
  • 33. Abduction is suitable for • Generating hypotheses that would explain an evidence. • Explanations expressed in terms of certain predicates, declared before hand as abducibles. 17 Monday 31 August 2009 17
  • 34. Abduction is suitable for False predicates • Generating hypotheses that could be true that would explain an evidence. • Explanations expressed in terms of certain predicates, declared before hand as abducibles. 17 Monday 31 August 2009 17
  • 35. Abduction is suitable for False predicates • Generating hypotheses that could be true that would explain an evidence. True predicates • Explanations expressed in that could be false terms of certain predicates, declared before hand as abducibles. 17 Monday 31 August 2009 17
  • 36. Abduction is suitable for Abducibles False predicates • Generating hypotheses that could be true that would explain an evidence. True predicates • Explanations expressed in that could be false terms of certain predicates, declared before hand as abducibles. We can think in “Abducibles” as “Correctables” 17 Monday 31 August 2009 17
  • 37. An example of abduction Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) broken-wing(?x). 18 Monday 31 August 2009 18
  • 38. An example of abduction Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) broken-wing(?x). Observation: flies(opus) 18 Monday 31 August 2009 18
  • 39. An example of abduction failing Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) broken-wing(?x). Observation: flies(opus) 18 Monday 31 August 2009 18
  • 40. An example of abduction failing Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) broken-wing(?x). bird(opus) added to our theory Observation: flies(opus) 18 Monday 31 August 2009 18
  • 41. An example of abduction succeeding Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) broken-wing(?x). bird(opus) added to our theory Observation: flies(opus) 18 Monday 31 August 2009 18
  • 42. An example of abduction Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) bird(tweety) broken-wing(?x). broken-wing(tweety) 19 Monday 31 August 2009 19
  • 43. An example of abduction Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) bird(tweety) broken-wing(?x). broken-wing(tweety) Observation: flies(tweety) 19 Monday 31 August 2009 19
  • 44. An example of abduction failing Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) bird(tweety) broken-wing(?x). broken-wing(tweety) Observation: flies(tweety) 19 Monday 31 August 2009 19
  • 45. An example of abduction failing Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) bird(tweety) broken-wing(?x). broken-wing(tweety) retracted from our theory Observation: flies(tweety) 19 Monday 31 August 2009 19
  • 46. An example of abduction succeeding Abducibles Theory: flies(?x) if bird(?x), not (ab(?x)) bird(?x). ab(?x) if broken-wing(?x) bird(tweety) broken-wing(?x). broken-wing(tweety) retracted from our theory Observation: flies(tweety) 19 Monday 31 August 2009 19
  • 47. How to choose abducible predicates ?-classChainReallyUnderstandMethodWithName(ExperimentalAction, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-superclassOf(?s, ExperimentalAction), classChainReallyUnderstandMethodWithName(?s, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-methodWithNameInClass(?m, undoAction, ExperimentalAction), methodWithBooleanReturnStatement(?m, true) - predicates that denote basic structural relationships - we know for sure that they will be evaluated as part of the resolution process of the query 20 Monday 31 August 2009 20
  • 48. How to choose abducible predicates ?-classChainReallyUnderstandMethodWithName(ExperimentalAction, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-superclassOf(?s, ExperimentalAction), classChainReallyUnderstandMethodWithName(?s, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-methodWithNameInClass(?m, undoAction, ExperimentalAction), methodWithBooleanReturnStatement(?m, true) - predicates that denote basic structural relationships - we know for sure that they will be evaluated as Primitive predicates that can be corrected part of the resolution process of the query 20 Monday 31 August 2009 20
  • 49. How to choose abducible predicates ?-classChainReallyUnderstandMethodWithName(ExperimentalAction, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-superclassOf(?s, ExperimentalAction), classChainReallyUnderstandMethodWithName(?s, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-methodWithNameInClass(?m, undoAction, ExperimentalAction), methodWithBooleanReturnStatement(?m, true) Primitive predicates that can be corrected 21 Monday 31 August 2009 21
  • 50. How to choose abducible predicates ?-classChainReallyUnderstandMethodWithName(ExperimentalAction, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-superclassOf(?s, ExperimentalAction), classChainReallyUnderstandMethodWithName(?s, ?m, undoAction), methodWithBooleanReturnStatement(?m, true) :-methodWithNameInClass(?m, undoAction, ExperimentalAction), methodWithBooleanReturnStatement(?m, true) Primitive predicates that can be corrected 21 Monday 31 August 2009 21
  • 51. Our framework allows ... • The definition of abducible predicates. • Declaration of multiple corrective actions. • Generation of hypotheses explaining inconsistencies. • Semi-automatic execution of corrective actions. 22 Monday 31 August 2009 22
  • 52. Defining positive explanations (new facts will be added to the theory) 23 Monday 31 August 2009 23
  • 53. Defining positive explanations (new facts will be added to the theory) Abducible predicate: in(methodWithBooleanReturnStatement(+? method,+?boolean)) 23 Monday 31 August 2009 23
  • 54. Defining positive explanations (new facts will be added to the theory) 24 Monday 31 August 2009 24
  • 55. Defining positive explanations (new facts will be added to the theory) Corrective action: [[?class compile: (?selector asString, ‘^’,?boolean asString)]] 24 Monday 31 August 2009 24
  • 56. Correcting inconsistencies 25 Monday 31 August 2009 25
  • 57. Correcting inconsistencies Correct 25 Monday 31 August 2009 25
  • 58. The corrective browser 26 Monday 31 August 2009 26
  • 59. The corrective browser Corrective action name 26 Monday 31 August 2009 26
  • 60. The corrective browser Corrective Textual description action name 26 Monday 31 August 2009 26
  • 61. The corrective browser Corrective Textual description action name Visualization in the proof three of where the corrective action was found 26 Monday 31 August 2009 26
  • 62. Visualisation of the nodes with corrective actions Color code: •Red filling means failure. •Thick green border means availability of corrective actions. 27 Monday 31 August 2009 27
  • 63. Visualisation of the nodes with corrective actions Color code: •Red filling means failure. •Thick green border means availability of corrective actions. 27 Monday 31 August 2009 27
  • 64. Future work • How to choose among different solutions. • Detect solutions that could cause new inconsistencies. 28 Monday 31 August 2009 28
  • 65. Conclusions • We can infer solutions from the rules that define consistencies. • A library of “primitive” solutions to small problems should be provided. • These solutions can be composed and reused across distinct problems. 29 Monday 31 August 2009 29
  • 66. Many Thanks ! Questions and feedback are welcomed 30 Monday 31 August 2009 30