Converted the if/else block in getType() to a series of helper methods.#5
Converted the if/else block in getType() to a series of helper methods.#5EmmaIreland wants to merge 3 commits intoNicMcPhee:masterfrom
Conversation
This allows the compiler to take responsibility for figuring out what type of inventory it is.
|
It looks like all the classes involved here are in org.bukkit instead of in net.minecraft. Is there any chance we could add a |
changed for us; added two @OVERRIDES that Eclipse removed.
|
The InventoryType objects that we return in most cases are in org.bukkit.event.inventory.InventoryType, which we do not have source code for; the types of inventory are in net.minecraft. So we think we can't do what you are suggesting, unless we are misunderstanding your suggestion. |
|
Code Review: Non-code Review: |
|
This was a very well done refactoring, both code and non-code. No complaints, my only real comment is this is a clever way of dealing with this issue. |
|
Do they follow the CraftBukkit guidelines? Is the English clear and professional? Is it clear what this pull request does, and why the CraftBukkit team should seriously consider accepting the pull request? Are the commit messages clear and helpful? (git allows you to edit commit messages after the fact.) Are there commits that should perhaps be merged into a single commit (which git allows you to do after the fact). Does the English description accurately and usefully capture the actual changes to the code? Does the pull request appropriately use the language of refactoring (e.g., names of smells, refactorings, and patterns)? Does the pull request describe what tests (if any) exist to support the change? (This would be important in helpful assess the associated risks.) Does the pull request represent a single, clearly definable change? Do the changes in the pull request represent a meaningful change that would justify the effort of the CraftBukkit team to process and incorporate the pull request? To what degree do the changes in the pull request reflect an "interesting" refactoring, i.e., reflect an understanding of the concepts and techniques we've been working with this semester? To what degree do you believe that the changes are correct? Why/why not? |
|
It would be nice to have a few simple tests here, especially to make sure that inheritance is being handled correctly (e.g., based on the comment about That said, I think this is a nice refactoring and definitely a step in a good direction. |
The issue:
There was a large if/else block in getType(). It was exclusively an if/else block that checked types of inventory.
Justification:
This method can introduce inefficiencies because the cases are always checked in the same order (by necessity). By allowing the compiler to take care of figuring out which type of IInventory is being passed in, we reduce overhead.
Breakdown:
The cases in the if/else block were separated and put into smaller helper methods. Each method took a different type of inventory and the body of the method was determined by the body of the corresponding if-statement.
Testing:
Unfortunately there are no existing tests that cover this code. However it is a relatively simple refactoring, and we are confident that it still functions correctly.