Cha-Q FOD Financin pilot study Calcul IPP project: Simulation - - PowerPoint PPT Presentation

cha q fod financi n pilot study
SMART_READER_LITE
LIVE PREVIEW

Cha-Q FOD Financin pilot study Calcul IPP project: Simulation - - PowerPoint PPT Presentation

Automating Systematic Edits with Cha-Q search-and-replace Presenters: Tim Molderez, Nick Nuyts Cha-Q FOD Financin pilot study Calcul IPP project: Simulation personal taxes 2 FOD Financin pilot study Calcul IPP project:


slide-1
SLIDE 1

Automating Systematic Edits
 with Cha-Q search-and-replace

Presenters: Tim Molderez, Nick Nuyts

Cha-Q

slide-2
SLIDE 2

FOD Financiën pilot study

2

▪ Calcul IPP project: Simulation personal taxes

slide-3
SLIDE 3

FOD Financiën pilot study

2

▪ Calcul IPP project: Simulation personal taxes

▪ 2987 Java source files; 274883 LOC ▪ Examined development activity of Sep. 2014 - May 2016
 (751 commits)

slide-4
SLIDE 4

Introducing fields + usages

public class ReportCalcSummary implements Serializable { ... + private Long impotReferRegulPosVla; + public Long getImpotReferRegulPosVla() { + return impotReferRegulPosVla;} + public void setImpotReferRegulPosVla(Long impotReferRegulPosVla) { + this.impotReferRegulPosVla = impotReferRegulPosVla;} ... + .append("impotReferRegulPosVla = ").append(this.impotReferRegulPosVla).append(TAB) ... + dto.setImpotReferRegulPosVla(new Long(0)); ... + if (g8653 > 0) {dto.setImpotReferRegulPosVla(a(dto.getImpotReferRegulPosVla(), g8653));} ... + vo.setImpotReferRegulPosVla(dto.getImpotReferRegulPosVla()); ...

3

slide-5
SLIDE 5

Introducing fields + usages

public class ReportCalcSummary implements Serializable { ... + private Long impotReferRegulPosVla; + public Long getImpotReferRegulPosVla() { + return impotReferRegulPosVla;} + public void setImpotReferRegulPosVla(Long impotReferRegulPosVla) { + this.impotReferRegulPosVla = impotReferRegulPosVla;} ... + .append("impotReferRegulPosVla = ").append(this.impotReferRegulPosVla).append(TAB) ... + dto.setImpotReferRegulPosVla(new Long(0)); ... + if (g8653 > 0) {dto.setImpotReferRegulPosVla(a(dto.getImpotReferRegulPosVla(), g8653));} ... + vo.setImpotReferRegulPosVla(dto.getImpotReferRegulPosVla()); ...

3

A new field

slide-6
SLIDE 6

Introducing fields + usages

public class ReportCalcSummary implements Serializable { ... + private Long impotReferRegulPosVla; + public Long getImpotReferRegulPosVla() { + return impotReferRegulPosVla;} + public void setImpotReferRegulPosVla(Long impotReferRegulPosVla) { + this.impotReferRegulPosVla = impotReferRegulPosVla;} ... + .append("impotReferRegulPosVla = ").append(this.impotReferRegulPosVla).append(TAB) ... + dto.setImpotReferRegulPosVla(new Long(0)); ... + if (g8653 > 0) {dto.setImpotReferRegulPosVla(a(dto.getImpotReferRegulPosVla(), g8653));} ... + vo.setImpotReferRegulPosVla(dto.getImpotReferRegulPosVla()); ...

3

A new field Its getter

slide-7
SLIDE 7

Introducing fields + usages

public class ReportCalcSummary implements Serializable { ... + private Long impotReferRegulPosVla; + public Long getImpotReferRegulPosVla() { + return impotReferRegulPosVla;} + public void setImpotReferRegulPosVla(Long impotReferRegulPosVla) { + this.impotReferRegulPosVla = impotReferRegulPosVla;} ... + .append("impotReferRegulPosVla = ").append(this.impotReferRegulPosVla).append(TAB) ... + dto.setImpotReferRegulPosVla(new Long(0)); ... + if (g8653 > 0) {dto.setImpotReferRegulPosVla(a(dto.getImpotReferRegulPosVla(), g8653));} ... + vo.setImpotReferRegulPosVla(dto.getImpotReferRegulPosVla()); ...

3

A new field Its getter Its setter

slide-8
SLIDE 8

Introducing fields + usages

public class ReportCalcSummary implements Serializable { ... + private Long impotReferRegulPosVla; + public Long getImpotReferRegulPosVla() { + return impotReferRegulPosVla;} + public void setImpotReferRegulPosVla(Long impotReferRegulPosVla) { + this.impotReferRegulPosVla = impotReferRegulPosVla;} ... + .append("impotReferRegulPosVla = ").append(this.impotReferRegulPosVla).append(TAB) ... + dto.setImpotReferRegulPosVla(new Long(0)); ... + if (g8653 > 0) {dto.setImpotReferRegulPosVla(a(dto.getImpotReferRegulPosVla(), g8653));} ... + vo.setImpotReferRegulPosVla(dto.getImpotReferRegulPosVla()); ...

3

A new field Its getter Its setter Different usages of the field

slide-9
SLIDE 9

Systematic edits overview

4

Type # sys. edits

  • avg. instances

Adding similar call statements 38 53 Adding/removing similar fields 33 96.26 Adding similar if cases 13 21.92 Adding similar test cases 12 51.67 Generating similar classes 5 8.2 Formatting changes 5 63.6 Miscellaneous 14 33.5 Total 120

slide-10
SLIDE 10

Systematic edits overview

4

Type # sys. edits

  • avg. instances

Adding similar call statements 38 53 Adding/removing similar fields 33 96.26 Adding similar if cases 13 21.92 Adding similar test cases 12 51.67 Generating similar classes 5 8.2 Formatting changes 5 63.6 Miscellaneous 14 33.5 Total 120

▪ ~16% of commits containing systematic edits ▪ ~7% of commits are systematic edits related to 
 tax law changes → Likely to reoccur

slide-11
SLIDE 11

Cha-Q search-and-replace

5

slide-12
SLIDE 12

Cha-Q search-and-replace

▪ Systematic edits are unavoidable

5

slide-13
SLIDE 13

Cha-Q search-and-replace

▪ Systematic edits are unavoidable ▪ Repetitive and error-prone if done manually

5

slide-14
SLIDE 14

Cha-Q search-and-replace

▪ Systematic edits are unavoidable ▪ Repetitive and error-prone if done manually ▪ Automate it! ▪ Only describe the similar change once ▪ Tool can apply it to all locations

5

slide-15
SLIDE 15

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } }

slide-16
SLIDE 16

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } }

slide-17
SLIDE 17

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } }

A field of type EntityIdentifier

slide-18
SLIDE 18

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } }

A field of type EntityIdentifier An identifier of an entity .. but what kind of entity?

slide-19
SLIDE 19

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } }

A field of type EntityIdentifier An identifier of an entity .. but what kind of entity?

slide-20
SLIDE 20

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } } public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier<SimpleName> label; public EntityIdentifier<SimpleName> getLabel() { return label; } public void setLabel(EntityIdentifier<SimpleName> label) { this.label = label; } }

A field of type EntityIdentifier An identifier of an entity .. but what kind of entity?

slide-21
SLIDE 21

Example systematic edit

6

public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier label; public EntityIdentifier getLabel() { return label; } public void setLabel(EntityIdentifier label) { this.label = label; } } public class BreakStatement extends Statement { @EntityProperty(value = SimpleName.class) private EntityIdentifier<SimpleName> label; public EntityIdentifier<SimpleName> getLabel() { return label; } public void setLabel(EntityIdentifier<SimpleName> label) { this.label = label; } }

A field of type EntityIdentifier Used as type parameter An identifier of an entity .. but what kind of entity?

slide-22
SLIDE 22

State of the art: 2 extremes

7

Search-replace Transformation languages

slide-23
SLIDE 23

Cha-Q search-and-replace

Demo 1

slide-24
SLIDE 24

Cha-Q search-and-replace

Search template

Demo 1

slide-25
SLIDE 25

Cha-Q search-and-replace

Search template Replacement template

Demo 1

slide-26
SLIDE 26

Cha-Q search-and-replace

Demo 1

slide-27
SLIDE 27

Demo 2

slide-28
SLIDE 28

Placeholder variable

Demo 2

slide-29
SLIDE 29

Placeholder variable

Demo 2

Wildcard

slide-30
SLIDE 30

Demo 2

slide-31
SLIDE 31

Demo 2

This field was not found!

slide-32
SLIDE 32

Demo 3

slide-33
SLIDE 33

Demo 3

Directive, to add more control to searches

slide-34
SLIDE 34

Demo 3

Directive, to add more control to searches Attached to this piece of code

slide-35
SLIDE 35

Demo 3

slide-36
SLIDE 36

Demo 4

slide-37
SLIDE 37

Demo 4

This piece of code needs to change

slide-38
SLIDE 38

Demo 4

This piece of code needs to change ?fieldType now refers to it

slide-39
SLIDE 39

Demo 4

slide-40
SLIDE 40

Demo 4

Rewriting directive: replace the value of ?fieldType ..

slide-41
SLIDE 41

Demo 4

Rewriting directive: replace the value of ?fieldType .. .. with this new piece of code.

slide-42
SLIDE 42

Demo 4

slide-43
SLIDE 43

Demo 5

Replace field declaration, getter and setter

slide-44
SLIDE 44

Demo 5

Replace field declaration, getter and setter

slide-45
SLIDE 45

Cha-Q search-and-replace

13

slide-46
SLIDE 46

Cha-Q search-and-replace

13

▪ FOD Financiën pilot study:

▪ ~62% of systematic edits can be fully automated ▪ Remainder can be partially automated

slide-47
SLIDE 47

Cha-Q search-and-replace

13

▪ FOD Financiën pilot study:

▪ ~62% of systematic edits can be fully automated ▪ Remainder can be partially automated

▪ What can Cha-Q search-and-replace do for you?

find and fix all occurrences of the same bug upgrade existing clients to a newer API version create custom refactorings co-maintain multiple system variants evolve existing code to newer versions of Java automate repeating maintenance tasks

slide-48
SLIDE 48

Cha-Q search-and-replace

13

▪ FOD Financiën pilot study:

▪ ~62% of systematic edits can be fully automated ▪ Remainder can be partially automated

▪ What can Cha-Q search-and-replace do for you?

find and fix all occurrences of the same bug upgrade existing clients to a newer API version create custom refactorings co-maintain multiple system variants evolve existing code to newer versions of Java automate repeating maintenance tasks tmoldere@vub.ac.be - @timmolderez