CSC/ECE 517 Fall 2009/wiki 1a 7a HJ: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:


According 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."
According 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 ==
== Goals of refactoring ==


Refactoring is motivated by the difficulty of adding new functionality to a program. or fixing a bug in it.
Refactoring is motivated by the difficulty of adding new functionality to a program. or fixing a bug in it.


As we said berfore, after code refactoring, the program does the the exact same thing it did before.
As we said berfore, after code refactoring, the program does the the exact same thing it did before.
The differences are that the new code:
The differences are that the new code:
{|
{|
Line 20: Line 23:
|-
|-
|  5) could lead to a faster compilation time
|  5) could lead to a faster compilation time
|-
|}
== Common Refactorings for JAVA ==
Here is a list of some examples of refactoring. For further information, the reader please refer to Lecture 3 of CSC 517 of Dr. Gehringer and to the section 2.1.2.
{|
|  1) Rename
    {|
    |    a) Methods
    |-
    |    b) Fields
    |-
    |    c) Packages
    |-
    |    d) Projects
    |-
    |    e) Parameters
    |-
    |    f) Local Variables
    |-
    |}
|-
|  2) Encapsulate Field
|-
|  3) Pull up
    {|
    |    a) Field
    |-
    |    b) Method
    |-
    |}
|-
|  4) Push down
    {|
    |    a) Field
    |-
    |    b) Method
    |-
    |}
|-
|  5) Extract from an Expression
    {|
    |    a) Method
    |-
    |    b) Constant
    |-
    |    c) Local Variables
    |-
    |}
|-
|  6) Change Method Signature
|-
|-
|}
|}

Revision as of 20:06, 8 September 2009

Definition of code refactoring

According 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 berfore, after code refactoring, the program does the the exact same thing it did before.

The differences are that the new code:

1) is easier to read and so to understand
2) contains less duplication
3) is less complex
4) is more flexible towards future changes
5) could lead to a faster compilation time


Common Refactorings for JAVA

Here is a list of some examples of refactoring. For further information, the reader please refer to Lecture 3 of CSC 517 of Dr. Gehringer and to the section 2.1.2.

1) Rename
a) Methods
b) Fields
c) Packages
d) Projects
e) Parameters
f) Local Variables
2) Encapsulate Field
3) Pull up
a) Field
b) Method
4) Push down
a) Field
b) Method
5) Extract from an Expression
a) Method
b) Constant
c) Local Variables
6) Change Method Signature