Diagnosis and semi-automatic correction of detected design inconsistencies in source code - Presentation Transcript
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
IntensiVE
(consistency checking)
11
Monday 31 August 2009 11
IntensiVE
(consistency checking)
Classes that
return true in the
isUndoable method
{
11
Monday 31 August 2009 11
IntensiVE
(consistency checking)
Classes that Classes that
return true in the implement the
isUndoable method undoAction method
{
11 {
Monday 31 August 2009 11
IntensiVE
(consistency checking)
This class does
But implements an
not return true at the
undoAction method
isUndoable method
12
Monday 31 August 2009 12
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
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
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
Correcting
Diagnosing
Corrective
framework
15
Monday 31 August 2009 15
What is diagnosis?
Generating
hypotheses
explaining
Abductive
abnormal reasoning
observations
16
Monday 31 August 2009 16
What is diagnosis?
Generating
hypotheses
explaining
Abductive
abnormal reasoning
observations
16
Monday 31 August 2009 16
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Defining positive explanations
(new facts will be added to the theory)
23
Monday 31 August 2009 23
Defining positive explanations
(new facts will be added to the theory)
Abducible predicate:
in(methodWithBooleanReturnStatement(+?
method,+?boolean))
23
Monday 31 August 2009 23
Defining positive explanations
(new facts will be added to the theory)
24
Monday 31 August 2009 24
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
Correcting inconsistencies
25
Monday 31 August 2009 25
Correcting inconsistencies
Correct
25
Monday 31 August 2009 25
The corrective browser
26
Monday 31 August 2009 26
The corrective browser
Corrective
action name
26
Monday 31 August 2009 26
The corrective browser
Corrective
Textual description
action name
26
Monday 31 August 2009 26
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
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
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
Future work
• How to choose among different solutions.
• Detect solutions that could cause new
inconsistencies.
28
Monday 31 August 2009 28
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
Many Thanks !
Questions and feedback are welcomed
30
Monday 31 August 2009 30
Diagnosis and semi-automatic correction of detected more
Diagnosis and semi-automatic correction of detected design inconsistencies in source code by Sergio Castro, Johan Brichau and Kim Mens, ESUG09, Brest, France less
0 comments
Post a comment