170 likes | 322 Views
eLearning Environment for Software Engineering Education (Refactoring Agent). A.Stoyanova-Doycheva University of Plovdiv. Content. Introduction rLE Architecture and Implementation Refactoring Knowledge Base Conclusions. Refactoring Agent.
E N D
eLearning Environment for Software Engineering Education (Refactoring Agent) 10th Workshop SEERE 5-12.09.2010 A.Stoyanova-Doycheva University of Plovdiv
Content • Introduction • rLE Architecture and Implementation • Refactoring Knowledge Base • Conclusions 10th Workshop SEERE 5-12.09.2010
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. 10th Workshop SEERE 5-12.09.2010
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. 10th Workshop SEERE 5-12.09.2010
Example: Refactoring Proposal(DynamicHTML) 10th Workshop SEERE 5-12.09.2010
Example: Automatic Refactoring 10th Workshop SEERE 5-12.09.2010
Example: Refactoring questionary (Replace Type Code with State/Strategy) 10th Workshop SEERE 5-12.09.2010
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 . 10th Workshop SEERE 5-12.09.2010
BES (JADE) FES (IDE) Refactoring Agent sensors Local Control effectors RAnalyzer RParser Refactoring Knowledge Base Refactoring classes Rules RA Architecture 10th Workshop SEERE 5-12.09.2010
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. 10th Workshop SEERE 5-12.09.2010
RA KB Implementation 10th Workshop SEERE 5-12.09.2010
RA KB Pattern Package 10th Workshop SEERE 5-12.09.2010
A Refactoring Method Implementation (Decompose Conditional) 10th Workshop SEERE 5-12.09.2010
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. 10th Workshop SEERE 5-12.09.2010
“Automatic Refactoring” Methods • Add Parameter • Change Bidirectional Association to Unidirectional • Consolidate Duplicate Conditional Fragments • Convert Dynamic to Static Construction • Convert Static to Dynamic Construction • Decompose Conditional • Encapsulate Downcast • Introduce Explaining Variable • Parameterize Method • Preserve Whole Object • Preserve Whole Object • Reduce Scope of Variable • Remove Assignments to Parameters • Remove Control Flag • Replace Assignment with Initialization • Replace Magic Number with Symbolic Constant • Replace Nested Conditional with Guard Clauses • Replace Parameter with Explicit Methods • Replace Static Variable with Parameter • Reverse Conditional • Self Encapsulate Field 10th Workshop SEERE 5-12.09.2010
“Refactoring Proposal” Methods • Introduce Null Object • Introduce Parameter Object • Replace Array with Object • Replace Constructor with Factory Method • Replace Conditional with Polymorphism • Replace Error Code with Exception • Replace Exception with Test • Replace Parameter with Method • Replace Recursion with Iteration 10th Workshop SEERE 5-12.09.2010
“Refactoring Questionary” Methods • Replace Type Code with Class • Replace Type Code with State/Strategy • Replace Type Code with Subclass 10th Workshop SEERE 5-12.09.2010