Refactoring: Replaced 2 Switch statements with HashMaps#11
Refactoring: Replaced 2 Switch statements with HashMaps#11alexemmons wants to merge 2 commits intoNicMcPhee:masterfrom
Conversation
|
This is for pull request #11b. This was also made in a google doc that was shared with Nic. Non Code Review
Code Review
|
|
11b. Noncode review: Englishness: I do think that you were using professional English in the appended commit message, however it would've been nice to cite actual refactoring issues. So in that regard, professional word usage was foregone. I do believe that you made sure that the pull request was well-described and what specifically it aimed to do. You described the positives to accepting your pull request -- the benefits that your pull request offers. The commit messages were initially unhelpful, however the appended commit message was helpful. With that said, there was only one commit message and one fix, I'm unsure as to the path that you followed. I'm assuming your process was multistep and not just "we threw this code together and it seemed to be okay." I'd like to see your thought process during these steps. There was one commit message so it wasn't realistic to merge any commits. The English description does describe it somewhat. However, I'd like to see reasoning as to why these changes are actually refactorings and not changes in behavior (which... there totally is changes in behavior....) You do use the "switch statement" smell, but there are also other smells that you fixed (such as code duplication). I think that you were too conservative about the smells that you were describing, you only picked the obvious smell. You stated that there were no tests and that is correct. Code-Review: In my opinion, no. This was hastily done it seems and it is reflected in the fact that you no longer check for exceptions. They had that exception there for a reason and you shouldn't remove it just because it doesn't fit with your model. Given that you changed the behavior of the code (removed an exception check), this code pull request should probably not be taken into consideration as a pull request. I think that this refactoring focused on just a small portion of what we learned in class. We learned how to change a switch statement into a hashmap, and that's what they did. But they didn't use what we learned and went above and beyond to actually make this code that would be acceptable in industry. In my opinion, that's what this class was about. Learn the basics and learn how to apply those concepts in order to create meaningful refactorings that reflect industry-level code. The changes are not "correct." There is no longer the exception check and, as such, you would've likely broken hypothetical tests that check for that exception. They also missed the "up" case. As such, this code is not correct. |
|
11a Review: Non-code review: Code Review: |
|
I quite like the idea here, but constructing the map in the method (so it gets constructed anew _every time the method is called) is just a very bad idea. Also, leaving in the old logic as commented out code just adds clutter and looks really unprofessional. I take back my comment about commenting out the old code. You get full marks for reading their guidelines more carefully than I did and noticing that they ask you to leave code like that in, but commented out. I had missed (or forgotten) that entirely. That said, in my experience leaving code like that in is really odd and not the norm, and people are usually super grumpy when they run across something like that. I suspect that the CraftBukkit people want to be able to see what's being deleted when they discuss the pull request (but you can in the code diffs, so it's odd), and will then remove it before finalizing the pull request. |
Refactoring 11a: Commit 17293b1
Replaced a switch statement in generateTree() with a HashMap generateTree.
Refactoring 11b: Commit 16c83f8
Replaced a switch getDataValue() with a HashMap setDataValue.