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




    ...
An inconsistency example



                                                AbstractAction
                               ...
An inconsistency example
                                 The command design pattern




                                 ...
An inconsistency example
                                 The command design pattern

                                  Co...
An inconsistency example
                                 The command design pattern

                                  Co...
An inconsistency example
                                 The command design pattern

                                  Co...
An inconsistency example
                                 The command design pattern

                                  Co...
An inconsistency example
                                 The command design pattern

                                  Co...
An inconsistency example
                            The command design pattern

                             Consistency ...
Inconsistency management
                                 activities
                                                     ...
Inconsistency management
                                 activities
                                             Correcti...
Inconsistency management
                                 activities
                                                    E...
Inconsistency management
                                 activities
                                                     ...
IntensiVE

                        ( http://www.intensive.be )


       Inconsistency
         detection



       User-de...
Defining and verifying
                        constraints using IntensiVE

                   • Many kind of checks.
     ...
Verification of the Undoable Actions
                         constraint
                                   Consistency pro...
Verification of the Undoable Actions
                QUERY:   constraint
classChainReallyUnderstandsMethodWith
     Name(?c...
Verification of the Undoable Actions
                QUERY:   constraint
classChainReallyUnderstandsMethodWith
            ...
Verification of the Undoable Actions
                QUERY:   constraint
classChainReallyUnderstandsMethodWith
            ...
Verification of alternative views
                QUERY:                                                                   ...
Verification of alternative views
                QUERY:                                                                   ...
IntensiVE
                        (consistency checking)




                             11
Monday 31 August 2009        ...
IntensiVE
                        (consistency checking)

                                  Classes that
                 ...
IntensiVE
                        (consistency checking)

                                  Classes that         Classes t...
IntensiVE
                         (consistency checking)




                           This class does
                 ...
IntensiVE
                         (consistency checking)




  ExperimentalAction       This class does
                 ...
IntensiVE
                           (diagnosing inconsistencies)




  ExperimentalAction




                           ...
Inconsistency management
                                 activities
                                                     ...
Correcting




         Diagnosing
                        Corrective
                        framework




              ...
What is diagnosis?

         Generating
         hypotheses
         explaining
                                      Abdu...
What is diagnosis?

         Generating
         hypotheses
         explaining
                                      Abdu...
What is diagnosis?

         Generating
         hypotheses
         explaining
                                      Abdu...
Abduction is suitable for


         • Generating hypotheses
                that would explain an
                evidenc...
Abduction is suitable for

                                                  False
                                       ...
Abduction is suitable for

                                                  False
                                       ...
Abduction is suitable for
                                                 Abducibles
                                    ...
An example of abduction
                                                 Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                                 Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                   failing       Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                   failing       Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                 succeeding      Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                                 Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                                 Abducibles
          Theory:
          flies(?x) i...
An example of abduction
                                           failing     Abducibles
          Theory:
          flies...
An example of abduction
                                           failing      Abducibles
          Theory:
          flie...
An example of abduction
                                           succeeding     Abducibles
          Theory:
          fl...
How to choose abducible
                              predicates
                ?-classChainReallyUnderstandMethodWithNam...
How to choose abducible
                              predicates
                ?-classChainReallyUnderstandMethodWithNam...
How to choose abducible
                              predicates
                ?-classChainReallyUnderstandMethodWithNam...
How to choose abducible
                              predicates
                ?-classChainReallyUnderstandMethodWithNam...
Our framework allows ...

                   • The definition of abducible predicates.
                   • Declaration of ...
Defining positive explanations
                               (new facts will be added to the theory)




                 ...
Defining positive explanations
                               (new facts will be added to the theory)




                 ...
Defining positive explanations
                               (new facts will be added to the theory)




                 ...
Defining positive explanations
                               (new facts will be added to the theory)




                 ...
Correcting inconsistencies




                                    25
Monday 31 August 2009                               ...
Correcting inconsistencies




                                                 Correct


                                ...
The corrective browser




                                  26
Monday 31 August 2009                            26
The corrective browser
                         Corrective
                        action name




                       ...
The corrective browser
                         Corrective
                                            Textual description...
The corrective browser
                         Corrective
                                             Textual descriptio...
Visualisation of the nodes with
                               corrective actions




           Color code:
 •Red filling ...
Visualisation of the nodes with
                               corrective actions




           Color code:
 •Red filling ...
Future work



                   • How to choose among different solutions.
                   • Detect solutions that co...
Conclusions

                   • We can infer solutions from the rules that
                        define consistencies.
...
Many Thanks !



                        Questions and feedback are welcomed




                                         ...
Upcoming SlideShare
Loading in …5
×

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

496 views
426 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

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
496
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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

  1. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 14. IntensiVE ( http://www.intensive.be ) Inconsistency detection User-defined consistency definitions 7 Monday 31 August 2009 7
  15. 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. 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. 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. 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. 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. 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. 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. 22. IntensiVE (consistency checking) 11 Monday 31 August 2009 11
  23. 23. IntensiVE (consistency checking) Classes that return true in the isUndoable method { 11 Monday 31 August 2009 11
  24. 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. 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. 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. 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. 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. 29. Correcting Diagnosing Corrective framework 15 Monday 31 August 2009 15
  30. 30. What is diagnosis? Generating hypotheses explaining Abductive abnormal reasoning observations 16 Monday 31 August 2009 16
  31. 31. What is diagnosis? Generating hypotheses explaining Abductive abnormal reasoning observations 16 Monday 31 August 2009 16
  32. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 52. Defining positive explanations (new facts will be added to the theory) 23 Monday 31 August 2009 23
  53. 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. 54. Defining positive explanations (new facts will be added to the theory) 24 Monday 31 August 2009 24
  55. 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. 56. Correcting inconsistencies 25 Monday 31 August 2009 25
  57. 57. Correcting inconsistencies Correct 25 Monday 31 August 2009 25
  58. 58. The corrective browser 26 Monday 31 August 2009 26
  59. 59. The corrective browser Corrective action name 26 Monday 31 August 2009 26
  60. 60. The corrective browser Corrective Textual description action name 26 Monday 31 August 2009 26
  61. 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. 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. 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. 64. Future work • How to choose among different solutions. • Detect solutions that could cause new inconsistencies. 28 Monday 31 August 2009 28
  65. 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. 66. Many Thanks ! Questions and feedback are welcomed 30 Monday 31 August 2009 30

×