CSC/ECE 517 Spring 2022 - E2228. Refactor JavaScript on Expertiza

From Expertiza_Wiki
Revision as of 23:19, 6 April 2022 by Sskarra (talk | contribs) (Created page with "== Problem Statement== Refactor JavaScript on Expertiza for but not limited to the Assignment View == Background == Expertiza’s primary language for managing views is JavaS...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Problem Statement

Refactor JavaScript on Expertiza for but not limited to the Assignment View

Background

Expertiza’s primary language for managing views is JavaScript. However, these scripts are not well structured and present a large scope of improvement in terms of code quality and optimization.

Issues with existing functionality

  • assignments/edit/_due_dates.html.erb -> 470 lines of JS.
  • assignments/edit/_rubrics.html.erb -> 400 lines of JS.
  • assignments/_general.html.erb -> ~200 lines of JS.
  • hasTeamsChanged has violated the DRY principle. It adds input fields and handles checkboxes hidden states in other views. Every UI element that depends on hasTeams? checkbox should add a listener in their own view's js file. (Refer assignments/edit/_review_strategy.html.erb line 203 for reference).
  • assignments/edit.html.erb -> 76 lines of JS

What needs to be done

  • Extract non-ruby js functions into a separate file.
  • Find a solution to get rid of the ruby part in the JavaScript and extract those functions out of the html file too.
  • Optimize the code so that it follows DRY principles.
  • Very few code comments present. Add comments for the functions, explaining what the method does.
  • Introduce Single Responsibility Principle - A method/function should only have one purpose to fulfill (Read more about it here) and increase code reusability.
  • Identify and fix functions are useless and do not serve any purpose.