|
Homework 5.6 was asking me to re factor the code in functions hashtableupdate and hashtablelookup. When I go to look at this functions they are already 6 lines of code or less and contain no while loops and the only thing that I could re factor is a for loop but that would not really save any lines of code. I guess I'm a little confused on what the question wants me to do. |
|
If you look at the two functions they mention you hopefully see duplicate code in both of them. The exercise is wanting you to eliminate the duplicate code from those two functions by creating a new function that encapsulates that task that's being duplicated and have the functions that have duplicate code call your new function to obtain the information it needs to perform. Hit this and search for 'Extract Method' for a bit more. To be honest it's not much more but you may enjoy reading about other refactoring techniques. |