CSC/ECE 517 Fall 2022 - E2274: Refactor teams controller.rb

From Expertiza_Wiki
Revision as of 20:24, 14 November 2022 by Jlholle2 (talk | contribs) (Edit description of issue 4)
Jump to navigation Jump to search

Introduction

In this project we refactored teams_controller.rb and added tests associated with its functionality. Before we worked on it, teams_controller.rb had some minor parts of a few methods that could be improved. More comments can be added to improve the readability of methods in the file as well as code more understandable for what custom methods do. Furthermore, test coverage could be improved.

Previous Work

Prior work can be found here. This work was done in spring 2022, and it mainly consisted of refactoring a few methods such as delete, inherit, and bequeath_all. It also added new methods like init_team_type, get_parent_by_id, get_parent_from_child.

More recently, work was done by us from first part of the OSS project, which can be found here. This revision involved refactoring the methods like create_teams method, which involved renaming it to randomize_teams. The delete method was refactored to improve how teams were removed from the waitlist. The inherit method was also refactored to be renamed to copy_to_assignment and part of the code was moved to the custom method copy_teams_to_collection in Team model (team.rb). Furthermore, bequeath_all was also refactored to remove nested if statements and other returns so the method is easier to follow from looking at it.

Issues Being Worked on

  • More comments need to be added to the controller to briefly explain functionality of custom methods.
  • Find and fix any code where the DRY principle can be applied. Two places that will be taken a look at for this are the create and update methods.
  • Try to refactor the update method to make it cleaner.
  • There are few methods such as team_size, team_parent which will be removed.
  • Fix the code and Hindi text in config/locales/hi_IN.yml.
  • Add tests to increase test coverage by 10-20% if able.

Issue 1 Add Comments

We plan to add a comment describing the functionality of the following methods.

  • list
  • new
  • update
  • edit
  • delete_all
  • delete

Issue 2 Dry Code

Issue 3 Refactor Update

Issue 4 Remove Methods

We will analyze teams_controller to find unused or one-line methods such as team_size and team_parent and remove or refactor them to clean up the code. The goal of this task is to remove unused or extra code to make the controller easier to read and understand.

Issue 5 Update Translations

Issue 6 Test Coverage