13.7.2017 г. ENVIRONMENT FOR SOFTWARE ENGINEERING EDUCATION (REFACTORING AGENT) 1 A.Stoyanova-Doycheva University of Plovdiv 10th Workshop SEERE 5-12.09.2010 ELEARNING 13.7.2017 г. CONTENT Introduction rLE Architecture and Implementation Refactoring Knowledge Base Conclusions 10th Workshop SEERE 5-12.09.2010 2 10th Workshop SEERE 5-12.09.2010 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. 13.7.2017 г. REFACTORING AGENT 3 13.7.2017 г. RA FUNCTIONALITY 10th Workshop SEERE 5-12.09.2010 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. 4 Example: Refactoring Proposal (Dynamic HTML) 13.7.2017 г. 10th Workshop SEERE 5-12.09.2010 5 Example: Automatic Refactoring 13.7.2017 г. 10th Workshop SEERE 5-12.09.2010 6 Example: Refactoring questionary (Replace Type Code with State/Strategy) 13.7.2017 г. 10th Workshop SEERE 5-12.09.2010 7 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 13.7.2017 г. IMPLEMENTATION 8 BES (JADE) 13.7.2017 г. RA ARCHITECTURE FES (IDE) 10th Workshop SEERE 5-12.09.2010 sensors Refactoring Agent Local Control RParser effectors RAnalyzer Refactoring Knowledge Base Refactoring classes Rules 9 10th Workshop SEERE 5-12.09.2010 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. 13.7.2017 г. RA KNOWLEDGE BASE 10 13.7.2017 г. RA KB IMPLEMENTATION 10th Workshop SEERE 5-12.09.2010 11 RA KB PATTERN PACKAGE 13.7.2017 г. 10th Workshop SEERE 5-12.09.2010 12 13.7.2017 г. A REFACTORING METHOD IMPLEMENTATION (DECOMPOSE CONDITIONAL) 10th Workshop SEERE 5-12.09.2010 13 10th Workshop SEERE 5-12.09.2010 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. 13.7.2017 г. REFACTORING METHODS 14 1. 2. 4. 5. 6. 7. 8. 9. 10. 10. Preserve Whole Object 11. Reduce Scope of Variable 12. Remove Assignments to Parameters 13. Remove Control Flag 14. Replace Assignment with Initialization 15. Replace Magic Number with Symbolic Constant 16. Replace Nested Conditional with Guard Clauses 17. Replace Parameter with Explicit Methods 18. Replace Static Variable with Parameter 19. Reverse Conditional 20. Self Encapsulate Field 10th Workshop SEERE 5-12.09.2010 3. 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 13.7.2017 г. “AUTOMATIC REFACTORING” METHODS 15 1. 3. 4. 5. 6. 7. 8. 9. 10th Workshop SEERE 5-12.09.2010 2. 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 13.7.2017 г. “REFACTORING PROPOSAL” METHODS 16 1. 3. 10th Workshop SEERE 5-12.09.2010 2. Replace Type Code with Class Replace Type Code with State/Strategy Replace Type Code with Subclass 13.7.2017 г. “REFACTORING QUESTIONARY” METHODS 17
© Copyright 2025 Paperzz