1 ece 750 topic 8 meta-programming languages, systems, and applications evolving object-oriented...

33
1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings Lance Tokuda and Don Batory July 29, 2004 Presented by Shimin Li ECE750 University of waterloo

Upload: kerrie-morton

Post on 18-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

1

ECE 750 Topic 8

Meta-programming languages, systems, and applications

Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

July 29, 2004

Presented by Shimin Li

ECE750 University of waterloo

Page 2: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

2

Paper Overview

Page 3: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

3

Contents: Overview

Roughly five parts:

• Introduction• Overview of Refactorings• Examples of Evolving Applications• Lessons Learned from experiments• Related work and Conclusion

Page 4: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

4

Contents: Detail

• Introductio– Automate design level changes of source code– Preserve behavior

Page 5: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

5

Contents: Detail

• Overview of Refactorings– Definition of refactoring– Enabling conditions for refactorings

• Ensure refactorings preserve behavior

– Classification of object-oriented refactorings• Schema refactorings• Pattern refectorings• Language-specific refactorings

Page 6: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

6

Contents: Detail

• Examples of Evolving Applications– Why these examples have been chosen– Evolving CIM Works

• Version 2 to version 4• Nine steps, 81 refactorings, 486 lines of code modified

– Evolving CMU’s AUIS• Version 6.3 to version 8• Five steps, approximately 800 refactorings, 14K lines of code

modified

Page 7: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

7

Contents: Detail

• Lessons Learned from experiments– Refactoring benefits– Refactoring limitations– Future research– Implication for Java

Page 8: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

8

Related Work

• Bergstein: Object-preserving class transformations• Lieberherr: Object-extending class transformations

– In the Demeter OO software environment

• Opdyke: Refactoring definition• Refactorings were inspired by

– Banerjee and Kim: Schema evolutions– Johnson and Foote: Design principles– UIUC Choices operating system

• L. Tokuda: Refactorings implementation for C++• D. Roberts: Refactorings implementation for Smalltalk and design criteria for transformation tools• Pree: Hot spot meta patterns

Page 9: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

9

Future Work

• Granularity of transformation– Larger grain refactorings?

• Program families– How to transform a file used by multiple programs

– How to cope with different pre-processed versions of a single C++ file

• Integration with other tools– e.g. RationalRose, IDE

Page 10: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

10

Contributions and Novelties

• Implemented a set of refactorings

• Experimental studies– Showed refactorings can scale and useful on large,

real-world applications

– Revealed the benefits, limitations and research problems

Page 11: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

11

What I like

• Refactoring– Manipulate code in a safe environment– Recreate s situation where evolution is possible– Help to understand existing code

• The paper– Clear and concise– Helpful diagrams– Two meaningful examples

Page 12: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

12

What I don’t like

• Refactoring– It’s hard to detect if a program needs to be refactored

– Refactorings depends on a specific language and compiler

– May slow down the execution

• The Paper– Lack of explanation of refactorings and their enabling

conditions

Page 13: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

13

Discuss

Page 14: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

14

Question 1

What is refactoring?

Page 15: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

15

Answer 1

Refactoring is the process of changing a software

system in such a way that it does not alter the external

behavior of the code yet improves its internal structure.

– Martin Fowler

Page 16: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

16

Question 2

How does refactorings preserve behavior?

Page 17: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

17

Answer 2

Identify and satisfy a list of enabling conditions

for each refactorings(i.e. pre-conditions).

Page 18: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

18

Question 3

Explain the benefits of refactoring.

Page 19: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

19

Answer 3

• Automating design change• Reduce testing• Simpler design• Validation assistance• Ease of exploration• Re-use existing software

Page 20: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

20

Question 4

Explain the problems that the current refactoring

technique is facing.

Page 21: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

21

Answer 4

• Refactoring is risky(source code changing may introduce subtle bugs)

• Refactorings are dependent on a specific language and compiler(preprocessor directives)

• Program families

• Source codes have to be accessible

• Conservative enabling conditions(if it is too conservative, the transformation might be useless)

• Automated checking of enabling conditions

Page 22: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

22

Question 5

What are the prerequisites for a programmer

to refactor a program properly?

Page 23: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

23

Answer 5

• The programmer has to know what the program does and how it is structureed

• Know what he wants to change and how it can be completed

• Know what a particular refactoring does and what are the enabling conditions

Page 24: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

24

Question 6

What problems do program families cause in

refactoring?

Page 25: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

25

Answer 6

When transforming a file used by more than one program, it

is desirable for the transformation system to check enabling

conditions for all programs in which use that file. Otherwise,

a file might be transformed safely for one program while

causing another program which uses the same file to break.

Page 26: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

26

Question 7

What features of Java make its refactorings have

easier implementations than C++?

Page 27: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

27

Answer 7

• NO preprocessor• Not use makefile• Code placement is simplified since methods are stores

in a file belongs to the class• No free-floating procedures

Page 28: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

28

Question 8

Discuss the possible practical improvement of

refactorings.

Page 29: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

29

Answer 8

• Specify refactorings in a language-independent manner

• Apply refactorings at higher levels of abstraction

• Integrate refactoring with other tools• Automatically determine where and what

refactorings should be applied• Solve program families problem

Page 30: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

30

Question 9

Discuss the connections between AOP and

Refactoring.

Page 31: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

31

Answer 9

• AOP is a tool for expressing code in a structured form

• Refactoring is a tool changing the structure of existing code, hopefully to improve it

• In some case may achieve a better refactoring using AOP

• AOP can be used on either existing or new code

• Refactoring only can be used on existing code

• AOP might reduce the chance of refactoring?

Page 32: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

32

Question 10

How can we determine where and why refactorings

should be applied?

Page 33: 1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory

33

Answer 10

• Identify bad smells– Using Logic Meta Programming

– Other method?

• Future automatic tool