1 ece 750 topic 8 meta-programming languages, systems, and applications evolving object-oriented...
TRANSCRIPT
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
2
Paper Overview
3
Contents: Overview
Roughly five parts:
• Introduction• Overview of Refactorings• Examples of Evolving Applications• Lessons Learned from experiments• Related work and Conclusion
4
Contents: Detail
• Introductio– Automate design level changes of source code– Preserve behavior
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
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
7
Contents: Detail
• Lessons Learned from experiments– Refactoring benefits– Refactoring limitations– Future research– Implication for Java
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
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
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
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
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
13
Discuss
14
Question 1
What is refactoring?
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
16
Question 2
How does refactorings preserve behavior?
17
Answer 2
Identify and satisfy a list of enabling conditions
for each refactorings(i.e. pre-conditions).
18
Question 3
Explain the benefits of refactoring.
19
Answer 3
• Automating design change• Reduce testing• Simpler design• Validation assistance• Ease of exploration• Re-use existing software
20
Question 4
Explain the problems that the current refactoring
technique is facing.
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
22
Question 5
What are the prerequisites for a programmer
to refactor a program properly?
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
24
Question 6
What problems do program families cause in
refactoring?
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.
26
Question 7
What features of Java make its refactorings have
easier implementations than C++?
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
28
Question 8
Discuss the possible practical improvement of
refactorings.
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
30
Question 9
Discuss the connections between AOP and
Refactoring.
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?
32
Question 10
How can we determine where and why refactorings
should be applied?
33
Answer 10
• Identify bad smells– Using Logic Meta Programming
– Other method?
• Future automatic tool