e l earning e nvironment for s oftware e ngineering e ducation (r efactoring a gent )...

17
ELEARNING ENVIRONMENT FOR SOFTWARE ENGINEERING EDUCATION (REFACTORING AGENT) A.Stoyanova-Doycheva University of Plovdiv 1 4 . 0 6 . 2 2 1 0 t h W o r k s h o p S E E R E 5 - 1 2 . 0 9 . 2 0 1 0 1

Upload: sarah-oconnor

Post on 14-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

ELEARNING ENVIRONMENT FOR SOFTWARE ENGINEERING EDUCATION (REFACTORING AGENT)A.Stoyanova-Doycheva

University of Plovdiv

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

101

Page 2: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

CONTENT

Introduction rLE Architecture and Implementation Refactoring Knowledge Base Conclusions

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

2

Page 3: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

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.

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

3

Page 4: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

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.

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

4

Page 5: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

Example: Refactoring Proposal (Dynamic HTML)2

1.0

4.2

31

0th

Work

shop S

EER

E 5

-12

.09

.20

10

5

Page 6: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

Example: Automatic Refactoring2

1.0

4.2

31

0th

Work

shop S

EER

E 5

-12

.09

.20

10

6

Page 7: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

Example: Refactoring questionary

(Replace Type Code with State/Strategy)

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

7

Page 8: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

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 .

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

8

Page 9: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

RA ARCHITECTURE

Refactoring Knowledge Base

Refactoring Agent se

nsors

effecto

rs

Local Control

RAnalyzer RParser

Refactoring classes

BES (JADE) FES (IDE)

Rules

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

9

Page 10: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

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.

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

10

Page 11: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

RA KB IMPLEMENTATION

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

11

Page 12: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

RA KB PATTERN PACKAGE2

1.0

4.2

31

0th

Work

shop S

EER

E 5

-12

.09

.20

10

12

Page 13: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

A REFACTORING METHOD IMPLEMENTATION (DECOMPOSE CONDITIONAL)

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

13

Page 14: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

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.

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

14

Page 15: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

“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

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

15

Page 16: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

“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

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

16

Page 17: E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv 23.11.2015 г. 10th Workshop

“REFACTORING QUESTIONARY” METHODS

1. Replace Type Code with Class2. Replace Type Code with State/Strategy3. Replace Type Code with Subclass

21

.04

.23

10

th W

ork

shop S

EER

E 5

-12

.09

.20

10

17