CSC/ECE 517 Fall 2009/wiki 1a 7a HJ: Difference between revisions
Line 149: | Line 149: | ||
{| class="wikitable" | {| class="wikitable" width="80%" align="center" | ||
|+ Comparaison of Refactoring Tools | |+ Comparaison of Refactoring Tools | ||
|- | |- | ||
Line 158: | Line 158: | ||
|- | |- | ||
|Rename | |Rename | ||
| width="33%" | | |||
|Rename | |Rename | ||
| | | width="33%" | | ||
|Move | |Move | ||
| width="33%" | | |||
|Move | |Move | ||
| | | width="33%" | | ||
|Extract Class | |Extract Class | ||
| width="33%" | | |||
|Convert Local Variable or Field | |Convert Local Variable or Field | ||
|- | |- | ||
Line 177: | Line 180: | ||
|} | |} | ||
{| class="wikitable" width="80%" align="center" | |||
|+ Tableau | |||
|- | |||
! scope=col | Colonne 1 | |||
! scope=col | Colonne 2 | |||
! scope=col | Colonne 3 | |||
|- | |||
| width="33%" | | |||
Contenu 1 | |||
| width="34%" | | |||
Contenu 2 | |||
| width="33%" rowspan="2" | | |||
Contenu 5 | |||
|- | |||
| width="33%" | | |||
contenu 3 | |||
| width="34%" | | |||
Contenu 4 | |||
|- | |||
| align="center" colspan="3" | | |||
Ligne 1 | |||
|} | |||
== Conclusion == | == Conclusion == |
Revision as of 05:46, 17 September 2009
Definition of code refactoring
According to Wikipedia: "Code refactoring is the process of changing a program's internal structure without modifying its external functional behavior or existing functionality with the goals of readability, maintainability, performance, extensibility and simplicity."
Goals of refactoring
Refactoring is motivated by the difficulty of adding new functionality to a program or fixing a bug in it.
As we said before, after code refactoring, the program does the the exact same thing it did before.
Refactoring is very useful to improve a program because a software can not be perfect when it is first developed.
Refactoring is one of the most useful tool for software engineer because they can write a rough design which work at first and then refactor the code when they conceive a better design.
The differences are that the new code:
- is easier to read and so to understand
- contains less duplication
- is less complex
- is more flexible towards future changes
- could lead to a faster compilation time
Common Refactorings Tools
Here is a list of some examples of refactoring techniques used. For further information, the reader please refer to Lecture 3 of CSC 517 of Dr. Gehringer [1] inspired of the site [2] and to the section 2.1.2 of the thesis of Thomas Corbat [3].
- Rename
- Methods
- Fields
- Packages
- Projects
- Parameters
- Local Variables
- Encapsulate Field
- Move
- Method
- Field
- Pull up
- Field
- Method
- Push down
- Field
- Method
- Extract
- Method
- Class
- Constant
- Local Variables
- Convert Local Variables to Field
- Change Method Signature
Examples of Refactoring
Examples of Refactoring for JAVA
JAVA has a lot of tools for refactoring. Here are some examples of Refactoring for JAVA :
Rename
First code
public class rename_Method {
static void WrongRenameMethod() { System.out.println("NC State"); }
}
Refactor by renaming
public class rename_Method {
static void ncsu(){ System.out.println("NC State"); }
}
Encapsulation
Examples of refactoring for Ruby
Ruby is still a newbie in refactoring . Here are some refactoring tools :
Rename
def FirstMethod
puts("NC State");
end
Refactor by renaming
def NCSU
puts("NC State");
end
Encapsulation
Current IDE and Refactoring
Current Java IDE and Refactoring
Most of Java IDE support refactoring.
Eclipse which is one of the most used JAVA IDE has a lot of
Current Ruby IDE and Refactoring
The following Current Ruby IDE do not support refactoring :
- Ruby in Steel
- Arachno Ruby
- FreeRIDE
- Mondrian Ruby IDE
The only current Ruby IDE with refactoring support are:
- RubyMine
- Eclipse with Aptana
Ruby and JAVA Refactoring Tools : a small comparaison
JAVA | Ruby | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Rename | Rename | Move | Move | Extract Class | Convert Local Variable or Field | |||||
Extract Super Class | Extract Constant | |||||||||
Encapsulate Field | ||||||||||
Introduce Parameter |
Colonne 1 | Colonne 2 | Colonne 3 |
---|---|---|
Contenu 1 |
Contenu 2 |
Contenu 5 |
contenu 3 |
Contenu 4 | |
Ligne 1 |
Conclusion
The differences between the two languages JAVA and Ruby is the number of methods available for refactoring and the number of IDE which support refactoring in the two languages.
JAVA has two times more options for refactoring and all of JAVA IDE support refactoring.
Ruby is like a children which is learning and improving his knowledge by trying to be inspired by what the other already have.
However, refactoring tools for both JAVA and Ruby are integrated into some IDE like Eclipse.
References
[1] http://courses.ncsu.edu/csc517/common/lectures/notes/lec3-f09.pdf
Refactoring and version control, CSC517, NCSU, Dr. Ed Gehringer
[2] http://www.refactoring.com
[3] Summary : http://subs.emis.de/LNI/Proceedings/Proceedings106/gi-proc-106-039.pdf
Complete Thesis: http://r2.ifs.hsr.ch/rubyrefactoring.pdf Refactoring Support for the Eclipse Ruby Development Tools HSR, University of Applied Science Rapperswil Diploma Thesis of Thomas Corbat, Lukas Felber and Mirko Stocker
[4] http://refactormycode.com/codes/recent/ruby
Forum for help on refactoring in Ruby
[5] http://refactormycode.com/codes/recent/java
Forum for help on refactoring in Java
[6] http://www.slideshare.net/jweiss/refactoring-ruby-on-rails-applications