Contenu connexe
Similaire à Refactoring (20)
Plus de Camilo Lopes (19)
Refactoring
- 1. AS – Global Business Services
Refactoring
For Programmers
Camilo Lopes
Brazilian Java AS Competency 12/12/08 © 2007 IBM Corporation
- 2. AS – Global Business Services
Topics to be addressed
Objective
Why Refactoring?
What is Refactoring ?
Advantage
When Refactoring
Tools
Results
Example Java
Questions
© 2007 IBM Corporation
2 Brazilian Java AS Competency 12/12/08
- 3. AS – Global Business Services
Objective
Assist in the development of system Object Oriented
implements in the Java language that have fall reusability of
code, maintaining hard and the add or adequacy of news
requirement sue a lot of work of engineer Software,
programmer, Analyst System, points that can generate big cost
the project.
© 2007 IBM Corporation
3 Brazilian Java AS Competency 12/12/08
- 4. AS – Global Business Services
Time x Spent
Time
Spent
Picture 1 believe that about 50% of time of an engineer Software is spent with task of maintaining
and comprehension of code.
Fonte: Maia (2004)
© 2007 IBM Corporation
4 Brazilian Java AS Competency 12/12/08
- 5. AS – Global Business Services
Cost x Spent
Cost
Spent
Picture 2 The long of last three decade more of 60% of cost of development of Software of
enterprise was spent with
© 2007 IBM Corporation
5 Brazilian Java AS Competency 12/12/08
- 6. AS – Global Business Services
Why Refactoring?
Refactoring help the become the code
more legible and solve problem of bad
code write
© 2007 IBM Corporation
6 Brazilian Java AS Competency 12/12/08
- 7. AS – Global Business Services
Definition Refactoring
Refactoring is the process of re-structure
the system without change your
functionality (Fowler,2004).
© 2007 IBM Corporation
7 Brazilian Java AS Competency 12/12/08
- 8. AS – Global Business Services
Motive to use Refactoring
Improve the project Software
Have a Software easier of comprehension the level
code
Programmer faster
© 2007 IBM Corporation
8 Brazilian Java AS Competency 12/12/08
- 9. AS – Global Business Services
Advantage
The technical of refactoring can be applicate in the
development and maintaining of Software;
Refactoring possibility the add of new functionality of
mode easy averting the re-structure of code;
With the use of refactoring spent less time possible in
maintaining the level code, improve the legibility and
structure the code.
© 2007 IBM Corporation
9 Brazilian Java AS Competency 12/12/08
- 10. AS – Global Business Services
Tools
Xrefactoring: the languages compatible are C and Java
this tools possibility the generation of documentation
on format HTML;
RefactorIT: is a tools to refactoring that can be integrate
in several IDEs.
Jfactor: is a tools that permit the application automatic
of refactoring the program in Java.
© 2007 IBM Corporation
10 Brazilian Java AS Competency 12/12/08
- 11. AS – Global Business Services
When Refactoring ?
Code duplicate;
Method long;
Comments superfluous;
Command switch
© 2007 IBM Corporation
11 Brazilian Java AS Competency 12/12/08
- 12. AS – Global Business Services
Results
Easy in the process of maintaining and
development of Software;
Can be applicate the any language Oriented
Object;
Become the Software flexible to add of new
functionality without re-structure of code;
Maintain the behavior of Software;
© 2007 IBM Corporation
12 Brazilian Java AS Competency 12/12/08
- 13. AS – Global Business Services
Example – Substitute a number literal by constant
symbolic
Are numbers with value special in system;
Sometimes are use in more of a place;
To make the reading and comprehension
double energiaPotencial(double massa,
double altura{
return massa * 9.81 * altura;
} // code do not refactoring
© 2007 IBM Corporation
13 Brazilian Java AS Competency 12/12/08
- 14. AS – Global Business Services
Code Factored
static final double CONSTANTE_GRAVITACIONAL = 9.81;
double energiaPotencial(double massa, double altura){
return massa * CONSTANTE_GRAVITACIONAL * altura;
}
MECHANICS
declare a constant and attribute a value to number
literal;
find where this number appear;
see if the change can be to do, case positive change the
number by constant;
compile and test.
© 2007 IBM Corporation
14 Brazilian Java AS Competency 12/12/08
- 15. AS – Global Business Services
Questions?!
Thanks!
http://camilolopes.wordpress.com
© 2007 IBM Corporation
15 Brazilian Java AS Competency 12/12/08