Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
JED Coweb Assignment 2
Refactoring (1 point)
Answer the following questions on refactoring.
Briefly, describe what refactoring is and why would you do it. In your description, include two signs that code should be refactored and how you would go about refactoring the code.
- Refactoring is the changing of code to make it better without adding additional functionality. Two signs that code should be refactored include increasing complexity in code as projects progress, and very lengthy functions relative to other parts of the program. As projects grow, special care should be taken to keep things as simple as they were, or you will be forced to refactor in the future when it becomes increasingly hard to make changes in the future. Regarding lengthy subroutines specifically, just as large classes can be broken into smaller classes logically, so should lengthy functions be able to be broken into smaller parts to improve readiblity and simplify things. How can unit testing be useful when refactoring code?
- Unit testing is important during the refactoring process because it simply automates the process of verifying that the refactoring changes that were made are not damaging to other parts of the program in any way. If the program is set up correctly with S Unit testing, and the tests bomb after refactoring, then the developer knows quickly what is causing the issue and what is responsible. If SUnit testing is not used, manual testing must occur with each large change to verify things are working properly, which duplicates effort.
Tracing Code (1 point)
1 + 2 3 & #8211; Cascade expected ->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) 2
Link to this Page
- Joel Davis last edited on 27 July 2006 at 9:25 pm by r50h125.res.gatech.edu