Skip to content

JDeodarant Refactoring

varsis edited this page Dec 2, 2013 · 31 revisions

Feature Envy

  1. Move Method com.uofa.adventure_app.controller.WebServiceController::httpWithType(com.uofa.adventure_app.controller.http.HttpObject):java.lang.String com.uofa.adventure_app.controller.http.HttpObject
    - This method does not belong in an object. It uses the object to load from the internet, but an object should not be aware of how it is used.
  2. Move Method com.uofa.adventure_app.activity.StoryActivity::openFragement(com.uofa.adventure_app.model.Fragement):void com.uofa.adventure_app.model.Fragement
    - Open Fragement is used in an activity, it has nothing to do with the object.
  3. Move Method com.uofa.adventure_app.controller.http.HttpObjectStory::publishObject(com.uofa.adventure_app.model.Story):com.uofa.adventure_app.controller.http.HttpObject com.uofa.adventure_app.model.Story
    - A object Story should not have to know how to publish an object
  4. Move Method com.uofa.adventure_app.activity.BrowserActivity::fetchStory(com.uofa.adventure_app.model.Story):void com.uofa.adventure_app.model.Story
    - This has nothing to do with the object.

Long Method

  1. com.uofa.adventure_app.activity.StoryActivity public void helpToast() helpText B1 0/8
    - Long due to setting static text, can't do much about it.
  2. com.uofa.adventure_app.activity.EditFragementActivity protected void onCreate(android.os.Bundle) authors B3 0/7 com.uofa.adventure_app.activity.EditStoryActivity protected void onCreate(android.os.Bundle) authors B3 0/7
    - Implemented Created new Method authorString() that reduces the size of the Method. Put in AdventureActivity.java
  3. com.uofa.adventure_app.model.Story public com.uofa.adventure_app.model.Story localCopy() c B7 0/7
    - Long method due to Deep Copy, Extracting method would cause more issues, and moves algorithm code around making it harder to understand.
  4. com.uofa.adventure_app.activity.EditFragementActivity public void save() currentFragement B1 0/5
    - is already a method, JDeodarant highlighted entire method.
  5. com.uofa.adventure_app.activity.BrowserActivity public void newStory() newFragement B1 0/3
    - Specific to the Activity, and creates a new story and sets the activity textView. Extracting moves specific lines of code to another method and make it harder to read.
  6. com.uofa.adventure_app.activity.FirstRunOnlyActivity public void okClicked(android.view.View) username B1 0/3
    - Implemented. Move Username to a getter method.
  7. com.uofa.adventure_app.activity.AnnotateActivity public void saveAnnotation() newAnnotation B1 0/2
    - This creates a new Annotation for the Next Cycle. Creates more and less readable code. 2 Lines of code only called once.
  8. com.uofa.adventure_app.activity.EditFragementActivity public void onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo) counter B1 1/8
    - Implemented Moved looping to it's own method. void addFragmentsToMenu() in EditFragementActivity.
  9. com.uofa.adventure_app.adapter.StoryGridAdapter public android.view.View getView(int, android.view.View, android.view.ViewGroup) authors B1 3/10
    - Implemented Moved author string generate method authorString in StoryGridAdapter()
  10. com.uofa.adventure_app.activity.FirstRunOnlyActivity public void okClicked(android.view.View) id B1 5/12
    - Implemented Extracted to getUserId() in FirstRunOnlyActivity.
  11. com.uofa.adventure_app.activity.AnnotateActivity protected void onActivityResult(int, int, android.content.Intent) newAnnotation B1 3/16
    - Attempted Try catches are different and was causing more issues. Makes more sense to leave them seperate, since they perform different Tasks.
  12. com.uofa.adventure_app.adapter.CustomListViewAdapter public android.view.View getView(int, android.view.View, android.view.ViewGroup) holder B1 1/4
    - Not sure what the problem is?
  13. com.uofa.adventure_app.activity.BrowserActivity public boolean onOptionsItemSelected(android.view.MenuItem) helpText B5 2/7
    - Implemented Extracted Method to toastHelp().
  14. com.uofa.adventure_app.model.Media public static android.graphics.Bitmap resizeImage(android.graphics.Bitmap) scale B1 1/3
    - Not useful to extract method.
  15. com.uofa.adventure_app.activity.EditFragementActivity public boolean onOptionsItemSelected(android.view.MenuItem) helpText B4 2/6
    - Implemented Extracted Method to toastHelp().
  16. com.uofa.adventure_app.activity.EditStoryActivity public boolean onOptionsItemSelected(android.view.MenuItem) helpText B3 2/5
    - Implemented Extracted Method to toastHelp().
  17. com.uofa.adventure_app.activity.AnnotateActivity protected void saveTextForView(android.view.View, java.lang.String) newAnnotation B1 2/4
    - Does not make sense.
  18. com.uofa.adventure_app.activity.StoryActivity public void onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo) counter B1 2/4
    - Counter used below, and will complicate code.
  19. com.uofa.adventure_app.activity.BrowserActivity public void dataReturn(ArrayList<com.uofa.adventure_app.model.Story>, java.lang.String) currentStory B1 7/10
    - Implemented Extracted methods from if statements in data return. Created getFragementData() and getStoryData().

God Classes

Most items returned was a Activity and was asking to remove functionality from the view.

Type Checking

Nothing returned.

Clone this wiki locally