Post on 05-Jan-2016
description
ELEARNING ENVIRONMENT FOR SOFTWARE ENGINEERING EDUCATION (REFACTORING AGENT)A.Stoyanova-Doycheva
University of Plovdiv
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
101
CONTENT
Introduction rLE Architecture and Implementation Refactoring Knowledge Base Conclusions
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
2
REFACTORING AGENT
The Refactoring Agent (RA) is a part from Refactoring Learning Environment, which is intended to analyze and assess programming code, based on refactoring rules.
The Refactoring Agent is responsible for the analysis and assessment of the code, written by students in real time by using a set of refactoring methods.
According to the situation and based on the refactoring method to be applied, the agent could react in different ways.
Its goal is to show the student, as much as possible, the weak places of their programming code and the possible ways to make it better.
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
3
RA FUNCTIONALITY
Depending on the refactoring method, which should be applied, the agent could react in three different ways: To apply automatically the method after
receiving confirmation from the user; To display detailed instructions, explaining to the
user where and how the particular refactoring method should be applied;
To ask the user additional questions in order to clarify the conditions and define the appropriate refactoring method.
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
4
Example: Refactoring Proposal (Dynamic HTML)2
0.0
4.2
31
0th
Work
shop S
EER
E 5
-12
.09
.20
10
5
Example: Automatic Refactoring2
0.0
4.2
31
0th
Work
shop S
EER
E 5
-12
.09
.20
10
6
Example: Refactoring questionary
(Replace Type Code with State/Strategy)
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
7
IMPLEMENTATION As a development environment we chose Eclipse
It is open source It supports a powerful mechanism for interaction
with external components in the form of plugins. This could be considered as a significant advantage of this particular environment which simplifies the integration of the Refactoring Agent (RA) in the development environment.
The sensors and effectors of the agent are realized in JADE and they use existing plugins in Eclipse.
The agent itself is implemented by means of the JADE environment .
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
8
RA ARCHITECTURE
Refactoring Knowledge Base
Refactoring Agent se
nsors
effecto
rs
Local Control
RAnalyzer RParser
Refactoring classes
BES (JADE) FES (IDE)
Rules
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
9
RA KNOWLEDGE BASE
The RKB consists of a set of rules together with a set of classes, which build a consistent knowledge base.
The rules are implemented as Java code and are specific for each refactoring method.
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
10
RA KB IMPLEMENTATION
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
11
RA KB PATTERN PACKAGE2
0.0
4.2
31
0th
Work
shop S
EER
E 5
-12
.09
.20
10
12
A REFACTORING METHOD IMPLEMENTATION (DECOMPOSE CONDITIONAL)
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
13
REFACTORING METHODS
As а source – Martin Fowler’s book “Refactoring – Improving the Design of Existing Code”
We discovered а total of 32 methods that can be implemented in the Knowledge Base.
We still have 34 methods to investigate.
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
14
“AUTOMATIC REFACTORING” METHODS1. Add Parameter2. Change Bidirectional
Association to Unidirectional
3. Consolidate Duplicate Conditional Fragments
4. Convert Dynamic to Static Construction
5. Convert Static to Dynamic Construction
6. Decompose Conditional7. Encapsulate Downcast8. Introduce Explaining
Variable9. Parameterize Method10. Preserve Whole Object
10. Preserve Whole Object11. Reduce Scope of Variable12. Remove Assignments to
Parameters13. Remove Control Flag14. Replace Assignment with
Initialization15. Replace Magic Number with
Symbolic Constant16. Replace Nested Conditional
with Guard Clauses17. Replace Parameter with
Explicit Methods18. Replace Static Variable with
Parameter19. Reverse Conditional20. Self Encapsulate Field
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
15
“REFACTORING PROPOSAL” METHODS
1. Introduce Null Object 2. Introduce Parameter Object3. Replace Array with Object4. Replace Constructor with Factory Method5. Replace Conditional with Polymorphism6. Replace Error Code with Exception7. Replace Exception with Test8. Replace Parameter with Method9. Replace Recursion with Iteration
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
16
“REFACTORING QUESTIONARY” METHODS
1. Replace Type Code with Class2. Replace Type Code with State/Strategy3. Replace Type Code with Subclass
20
.04
.23
10
th W
ork
shop S
EER
E 5
-12
.09
.20
10
17