View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

gtg842y CoWeb Assignment 2

the term refactoring means modifying source code without changing its user-end behavior, and is sometimes informally referred to as "cleaning it up". In extreme programming refactoring is an integral part of the software development cycle: developers alternate between adding new tests and functionality and refactoring the code to improve its internal consistency and clarity.

The most easiest kind of refactoring is the change the variable/method/ name to some thing that is meaningful. For example, instead of using "x" and "y" we could use terms such as "user" "password". A more complex version of refactoring is to turn the code within an if block into a subroutine. For example, I have this huge class with lots of "if" statement to track the conditions; so in the process of refactoring I could make these "if" statement to different methods so these methods are relatively independent to the remaining code. the advantage for this kind of refactoring is that it is easier to track program errors, so if one piece of method messed up it will not effect the entire program.

Unit testing allows the programmer to refactor code at a later date, and make sure the module still works correctly (i.e. regression testing). This provides the benefit of encouraging programmers to make changes to the code since it is easy for the programmer to check if the piece is still working properly. A good set of unit test cases makes sure that every line of code in the module executes.

In continuous unit testing environments, through the inherent practice of sustained maintenance, unit tests will continue to accurately reflect the intended use of the executable and code in the face of any change. Depending upon established practices and unit test coverage, up to the second accuracy can be maintained.

Tracing code
1 + 2 * 3 - 4 factorial    


a := #(1 2 3 4 5)
#(1 2 3 4 5)

a select: [:i | i odd]
#(1 3 5)

b := a
#(1 2 3 4 5)

a := a reversed
#(5 4 3 2 1)

b collect: [:i | i i]
#(1 4 9 16 25)

a perform: #at: withArguments: #(4)

Link to this Page