Skip to content

Project Part 4 Refactoring

Crumbtray edited this page Dec 3, 2012 · 1 revision

JDeodorant Analysis Results

Feature Envy

  • com.cmput301.classproject.Tests.SubmissionTests::testGetTimeStamp():void
  • com.cmput301.classproject.Tests.SubmissionTests::testGetTextSubmission():void
  • com.cmput301.classproject.Tests.SubmissionTests::testToString():void
  • com.cmput301.classproject.Tests.SubmissionTests::testGetSummary():void
  • com.cmput301.classproject.Tests.SubmissionTests::testGetAuthor():void
  • com.cmput301.classproject.Tests.SubmissionTests::testGetAccess():void
  • com.cmput301.classproject.Tests.TaskTests::testGetName():void
  • com.cmput301.classproject.Tests.TaskTests::testGetDescription():void
  • com.cmput301.classproject.Tests.TaskTests::testIsPublicAccess():void
  • com.cmput301.classproject.Tests.TaskTests::testGetRequires():void
  • com.cmput301.classproject.UI.ViewTaskActivity::requires():java.lang.String
  • com.cmput301.classproject.Tests.TaskTests::testGetCreator():void
  • com.cmput301.classproject.Tests.TaskTests::testSetId():void
  • com.cmput301.classproject.Tests.SubmissionTests::testAlterPhotos():void
  • com.cmput301.classproject.Tests.TaskTests::testTaskToString():void
  • com.cmput301.classproject.Tests.TaskTests::testAddSubmission():void
  • com.cmput301.classproject.Tests.JSONTests::addSubmission():void
  • com.cmput301.classproject.UI.ViewTaskActivity::addSubmission(com.cmput301.classproject.Model.Task, com.cmput301.classproject.Model.Submission):void
  • com.cmput301.classproject.Tests.JSONTests::testAddTask():void
  • com.cmput301.classproject.Tests.LocalStorageTests::testAddEntry():void

We chose not to implement the refactoring in this list because all test cases asides from 2 entries are involved with our testing scripts, which were crafted in that manner. Furthermore, the first non-testing entry pertains to a refactoring done in a separate JDeodorant analysis (Long Method), and the second non-testing entry alters a crucial wrapper component of our Android UI layout, which we do not want to refactor as it would completely change our design.

Long Method

  • com.cmput301.classproject.Model.Tasks.JSONServer.getLatestTask()
  • com.cmput301.classproject.Model.Tasks.JSONServer.addSubmission(java.lang.String,com.cmput301.classproject.Model.Submission, android.content.Context)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addSubmission(java.lang.String,com.cmput301.classproject.Model.Submission, android.content.Context)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task,android.content.Context)
  • com.cmput301.classproject.Model.Tasks.JSONServer.getAllTasks()
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.Model.Tasks.JSONServer.addTask(com.cmput301.classproject.Model.Task)
  • com.cmput301.classproject.UI.ViewTasksActivity.onCreate()

We refactored the last issue in our onCreate() method. Originally, it added the text in a big if/else chain, and it made sense to extract it into a method on its own. We have documented the new method, requires(), in the Javadoc and made it clear that it was refactored by JDeodorant.

We did not wish to touch the other refactoring options because they altered the JSONServer class drastically. We spend a lot of time refining the JSONServer class to allow for asynchronous syncing, and we felt that the refactoring would do more harm than better.

God Class

  • com.cmput301.classproject.UI.ViewTaskActivity

We did not implement this class extraction. The class extraction would create a class to abstract the task and its requirements. This does not make sense, as we have the requirements properties inside the task, and would be redundant to make a copy.

Type Checking

  • com.cmput301.classproject.UI.ViewTaskActivity.addSubmission(Task,Submission)
  • com.cmput301.classproject.Model.Tasks.ModifyServerData.doInBackground(Task[])

We did not implement these refactors because the refactoring would add 4 or more new classes to hold the data models, which consist of requirement data that we already have in our model classes, or single methods that interact with the JSON server. It does not make sense to us to have the model classes consist of smaller data classes, not does it make sense to make a class solely to implement one single method.