Refactorings - lagecamp/CMPUT301W13T02 GitHub Wiki

Some refactorings were implemented even before running JDeodorant for potential suggestions, such as:

  • Separation of classes into different packages (one for the model, one for the views and another one for the controller)

JDeodorant Results

denotes change has been implemented

God Classes:

RemoteRecipes

RecipeModel

Recipe

EditRecipeActivity

MainActivity

MyKitchen

SerializableImage

MyKitchenActivity

ElasticSearchRecipe

Controller

Long Methods:

RecipeModel.searchRecipe()

ViewRecipeActivity.update()

RemoteRecipes.postPicture()

EditRecipeActivity.update()

Controller.search() - no obvious way to shorten method, am not going to implement change

Controller.searchWithIngredients()

RemoteRecipes.search()

RecipeModel.replaceRecipe() - not going to change, method is very short. No idea why JDeodorant complained about this one

RemoteRecipe.postComment()

Recipe.addIngredient() - method is short enough

MyKitchen.sort()

RecipeModel.sortRecipes()

Type Checking:

ViewRecipeActivity.update() [Checks value of source]

EditRecipeActivity.onCreate() [Again, checks value of source]

Feature Envy:

No problems detected

Completed JDeodorant suggestions

RecipeModel.searchRecipe()

Have significantly reduced the size of this method by creating method containsKeywords() in recipe class. Now each recipe object can report if it contains a given keyword (as opposed to checking within the search method)

RecipeModel.sortRecipes()

Changed this method to use Collections.sort(), java's built in sorting method, instead of implementing the algorithm ourselves. Had to change Recipe to implement comparable.

MyKitchen.sort()

Like above, I changed this method to use Collections.sort(), java's built in sorting method, instead of implementing the algorithm ourselves. Had to change Ingredient to implement comparable.