Using Task Context to Improve Programmer...

34
SE Seminar Spring 09 - Reto Conconi Tuesday, March 17, 2009 1 Using Task Context to Improve Programmer Productivity Paper by: Mik Kersten and Gail C. Murphy, University of British Columbia Presented by: Reto Conconi, ETH Zürich

Transcript of Using Task Context to Improve Programmer...

SE Seminar Spring 09 - Reto ConconiTuesday, March 17, 2009 1

Using Task Context to Improve Programmer ProductivityPaper by: Mik Kersten and Gail C. Murphy, University of British ColumbiaPresented by: Reto Conconi, ETH Zürich

2

Imagine…

� … you work on a Java Project with thousands of classesand you have to refactor a class and the IDE would showyou only the elements related to the class you refactor.

� Furthermore: whenever you want to switch between twotasks the IDE adapts and remembers your last open filesand the relevant elements.

3

Mylyn

� Such a tool exists: Mylyn� Outcome of this research made by Mik Kersten and Gail C.

Murphy� Renamed Mylar to Mylyn due to legal problems� Today integrated in all eclipse packages except the classic

one.

4

Task

� Task Defintion: “a usually assigned piece of work often to be finished within a certain time”� Fixing a bug� Refactoring� Feature additions

5

First step: User defines task

6

Task Context for the User

� Information that a programmer needs to know to complete the task

7

Encoding User Interaction with IDE

� Track the events

8

Task context for Mylyn

� Task context: “…a graph of elements and relationships of program artifacts…”

� Build graph when processing history of interactions

� Nodes: Artifacts (e.g. a Java class or a method)� Edges represent relations that the user followed:

References, inheritance

9

Example

� Programmer navigates from the method call in class A to the method definition in class B (in Eclipse by pressing F3).

� This results in two “Selection” events in the history. One of the selection of the caller and a following one of the callee.

Calling method in

Class A

Called method in

Class B

Calling method in

Class A

Method definition

in Class B

Method calledin

Class A

10

Weighting the elements

� The weighting is called degree-of-interest (DOI)� DOI = Interest - Decay

� Interest based on Frequency� Decay based on Recency

11

Example Computation DOI of ResourceStructureBridge

� Total interest: 1 + 0 + 2 = 3� Total decay: (16-1) * 0.1 = 1.5� DOI = 1.5

Scaling:

• Selection � 1

• Commands � 0

• Edit � 2

• Decay � 0.1

12

Projecting task context

� Project a task context onto data structures in the GUI� Package Explorer

� Filter files which have a DOI under a certain threshold

� “Problems” – View� Resort warnings according to DOI

� SVN commit� Commit only changes belonging to the task

� Set of JUnit tests� Execute only tests relevant to the task context

13

Prediction

� Example:Task context

Class A

Class D

Class B

Class C

14

OverviewEncoding Interaction

Constructing a Task Context

Project and predict

15

Mylyn in action

� Video

16

Field study

� Announced study at EclipseCon March 05� Study ended 8 months later� 99 signed up via webpage and downloaded Mylyn Monitor for first� 16 survived the hard criteria:

0

500

1000

1500

2000

2500

3000

3500

4000

4500

Edit Events

Mylyn (Treatment phase)

only Mylyn Monitor (Base phase)

What the participant used:

1000 Edit events ~ 1-3 weeksfulltime programming

17

Field study results

Edit Ratio (= number of edits / number of selection s)

0.00

5.00

10.00

15.00

20.00

25.00

30.00

35.00

40.00

3 8 6 7 12 15 16 10 2 9 13 5 11 1 14 4

Participant

w/o Mylyn

w/ Mylyn

18

Problems of the study

� Maybe only early-adopters followed the call to try it out� Which typical industry programmer is allowed to use

unstable experimental software in a business environmentor has enough time to participate?

� 16 participants maybe insufficient� Results may depend on the development process

19

Shortcomings

� Related tasks: Task may not be a single atomic unit as seen by the tool� Solution may be to allow subtasks

� Task context lifecycle� Scaling and Treshold should change according to the size/hours of

work.

� Decay� The same DOI algorithm was used for all projections.� Problem: When commiting files to repository belonging to specific

task, all changed files should be commited and not only those with a high enough DOI.

� Solved since version 0.4 (in the study 0.3 was used)

20

Conclusion

� Pro� Task switching is very useful� Filtering helps you to focus on elements you need� You can enable/disable filtering with a single click

� Contra� Risk to overlook relevant elements/warnings because of filtering

� Personally I begun to use it regularly� I am using: Task switching, Task integration� I am not using: Filtering and Prediction

� Similar functions can be found in IBM Rational Team Concert http://www.jazz.net� Changesets per Task, Task Integration, (Task switching)

21

Storing context

� How to store the task context?

22

Storing context

� The whole event history is stored!

23

Storing context

� How to restore the task context?

24

Example Computation

� Total interest: 1 + 0 + 2 = 3� Total decay: (46-1) * 0.1 = 4.5� DOI = -1.5

Scaling:

• Selection � 1

• Commands � 0

• Edit � 2

• Decay � 0.1

Event Kind Origin Target(s)1 selection Package Explorer ResourceStructureBridge class

2-5 propagation Package Explorer .java file, package, folder, project6 command Rename refactoring ResourceStructureBridge class7 edit Java Editor ResourceStructureBridge declaration

8-16 propagation Refactoring monitor 4 XML and 5 Java references to ResourceStructureBridge17-46 selections Package Explorer Other Java classes (not ResourceStructureBridge)

25

Algorithm to compute the DOI

DOI(element, events)

elementEvents = getAllEventsWithTarget(element, even ts)

decayStart = elementEvents[0]

interest = 0

for each event in elementEvents {

interest += SCALING(KIND(event))

currDecay = DECAY(decayStart, event, events)

if interest < currDecay then {

decayStart = event

interest = SCALING(KIND(event))

}

}

totalDecay = DECAY(dacayStart, LAST(events), events)

return interest – totalDecay

DECAY(fromEvent, toEvent, eventSeq)

decayEvents = SUBSEQ(fromEvent, toEvent, eventSeq)

return |decayEvents| * SCALING(KIND-DECAY)

26

Example Computation

� Total interest: 1 = 1� Total decay: 1 * 0.1 = 0.1� DOI = 0.9

Scaling:

• Selection � 1

• Commands � 0

• Edit � 2

• Decay � 0.1

Event Kind Origin Target(s)1 selection Package Explorer ResourceStructureBridge class

2-5 propagation Package Explorer .java file, package, folder, project6 command Rename refactoring ResourceStructureBridge class7 edit Java Editor ResourceStructureBridge declaration

8-16 propagation Refactoring monitor 4 XML and 5 Java references to ResourceStructureBridge17-46 selections Package Explorer Other Java classes (not ResourceStructureBridge)

47 selection Package Explorer ResourceStructureBridge class

27

Implementation details

Bridge

Context Model

Domain structure

28

Implementation detail 2

� Structure bridges� Map elements of task context graph to

� Java Model (Java AST)

� XML: Plugin descriptors (plugin.xml)

� XML: Ant

� Generic files

� Tasks

� UI Bridge� Monitors user interactions� Adds selection, edit and command events to the event history

29

Operating on Task Contexts: Slicing

� Slicing allows to filter the task context for certain criteria.

Context Model

„Slice all files, which I edited“

Example: Slicing for SVN commit

30

Operating on Task Contexts: Composition

� Combine Task Contexts

Task Context 2Task Context 1

31

Operating on Task Contexts: Manipulation

� Programmer can override DOI algorithm

32

Cycles

� The called method has a recursive call in the definition. If the programmer follows the definition again cycles are possible.

Called method in

Class B

Calling method in

Class A

33

Multiple Edges between two nodes

Class B

Class A

reference inheritance

34

Significance of the study results

Edit ratio (#edits/#selections)id w/o Mylyn w/ Mylyn Difference

3 2.90 7.80 4.90 Null hypothesis: No or bad influence on edit ratio8 10.10 26.40 16.30 Alternative: Edit ratio increased6 14.10 36.00 21.90

7 2.60 5.40 2.80 Level of significance 5%12 2.70 5.40 2.70

15 1.70 3.30 1.60 Average 3.56316 8.80 13.00 4.20 Std. deviation 6.52610 5.80 8.20 2.40

2 11.30 14.80 3.50 t 2.1849 6.70 8.70 2.00 t(0.05,15) 1.75

13 6.80 7.40 0.60

5 4.10 4.30 0.20 t > t(0.05, 15) Null hypothesis is wrong11 2.20 2.20 0.00

1 7.70 6.90 -0.80 Edit ratio increase is significant14 15.90 13.50 -2.40

4 11.00 8.10 -2.90