CSC/ECE 517 Spring 2019 E1910 Refactor assignments controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
This wiki page is for the description of changes made under E1910 OSS assignment for Spring 2019, CSC/ECE 517.
This wiki page is for the description of changes made under E1910 OSS assignment for Spring 2019, CSC/ECE 517.


We have no deployed project since we did not change any functionality.  
We have not deployed this project since we did not change any functionality that would affect the user.  


== Expertiza Background==
== Expertiza Background==
Line 9: Line 9:
== Description of the current project ==
== Description of the current project ==


The assignments_controller has multiple functions with wrong naming convention, they are classic examples of bad function names. Few of the variables names used in the method can also be refactored to make it more relevant and understandable. In addition, functions code can be optimized to ensure that it follows DRY principle. Also, most of the functions have missing code comments, which should be added to the functions.
The assignments_controller has multiple functions with wrong naming convention, they are classic examples of bad function names. Few of the variables names used in the method can also be refactored to make it more relevant and understandable. In addition, functions code can be optimized to ensure that it follows 'Don't Repeat Yourself' (DRY) principle. Also, most of the functions have missing code comments, which should be added to the functions.


== Files modified in current project ==
== Files modified in current project ==


A controller was modified for this project namely:<br/>
The only controller modified for this project was the:<br/>
1. AssignmentsController <br/>
1. AssignmentsController <br/>


The method names that were updated are:
The updated methods:
   - handle_assignment_directory_path_nonexist_case_and_answer_tagging
   - handle_assignment_directory_path_nonexist_case_and_answer_tagging  
   - assignment_form_key_nonexist_case_handler
    -- nonexist_path_with_tagging
   - Handle_current_user_timezonepref_nil
   - assignment_form_key_nonexist_case_handler  
   - update_nil_dd_deadline_name
    -- assignment_saving
   - update_nil_dd_description_url
   - Handle_current_user_timezonepref_nil  
   - assignment_form_assignment_staggered_deadline?
    -- nil_timezone_handler
   - check_due_date_nameurl_not_empty
   - update_nil_dd_deadline_name  
   - update_feedback_assignment_form_attributes
    -- update_due_date_deadline_name
  - allowed_action?
   - update_nil_dd_description_url  
    -- update_due_date_description_url

   - assignment_form_assignment_staggered_deadline?
    -- assignment_staggered_deadline?
   - check_due_date_nameurl_not_empty  
    -- check_due_date_nameurl

   - update_feedback_assignment_form_attributes  
    -- update_feedback_attributes





=== AssignmentsController ===
=== AssignmentsController ===
   
   
This is a controller that helps instructors, TA's, administrators, and super-administrators create/update/edit/show/delete current and past assignments. We updated the afore mentioned method names to
This is a controller that helps instructors, TA's, administrators, and super-administrators create/update/edit/show/delete current and past assignments. We updated the afore mentioned method names so that the naming convention follows the DRY principle. Many of the method names were far too long or repetitive or unhelpful in understanding what the method actually completed.  
  - nonexist_path_with_tagging
 
  - assignment_saving
  - nil_timezone_handler
  - update_due_date_deadline_name
  - update_due_date_description_url

  - assignment_staggered_deadline?
  - check_due_date_nameurl

  - update_feedback_attributes

The action_allowed? method was updated to be less repetitive in the if-else statement. The 'else' was removed since it was an extension to a previous statement in the 'if' portion.  


There were many existing test cases for this controller. We have made sure that no test cases were violated by our changes. No changes were made to the views or model.
There were many existing test cases for this controller. We have made sure that no test cases were violated by our changes. No changes were made to the views or model.


This is the new method created after the above refactoring:
[[File:action_allowed changes.png]]


== Testing Details==
== Testing Details==


=== RSpec ===
=== RSpec ===
There were already quite a few test cases for the AssignmentsController. We have not added any new test but made sure that no tests were failing due to our changes. No changes were made to the views and model.
There were already quite a few test cases for the AssignmentsController. We have not added any new tests but made sure that no tests were failing due to our changes. No changes were made to the views and model.

Revision as of 20:42, 20 March 2019

This wiki page is for the description of changes made under E1910 OSS assignment for Spring 2019, CSC/ECE 517.

We have not deployed this project since we did not change any functionality that would affect the user.

Expertiza Background

Expertiza is an educational web application created and maintained by the joint efforts of the students and the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.

Description of the current project

The assignments_controller has multiple functions with wrong naming convention, they are classic examples of bad function names. Few of the variables names used in the method can also be refactored to make it more relevant and understandable. In addition, functions code can be optimized to ensure that it follows 'Don't Repeat Yourself' (DRY) principle. Also, most of the functions have missing code comments, which should be added to the functions.

Files modified in current project

The only controller modified for this project was the:
1. AssignmentsController

The updated methods:

 - handle_assignment_directory_path_nonexist_case_and_answer_tagging 
   -- nonexist_path_with_tagging
 - assignment_form_key_nonexist_case_handler 
   -- assignment_saving
 - Handle_current_user_timezonepref_nil 
   -- nil_timezone_handler
 - update_nil_dd_deadline_name 
   -- update_due_date_deadline_name
 - update_nil_dd_description_url 
   -- update_due_date_description_url

 - assignment_form_assignment_staggered_deadline? 
   -- assignment_staggered_deadline?
 - check_due_date_nameurl_not_empty 
   -- check_due_date_nameurl

 - update_feedback_assignment_form_attributes 
   -- update_feedback_attributes



AssignmentsController

This is a controller that helps instructors, TA's, administrators, and super-administrators create/update/edit/show/delete current and past assignments. We updated the afore mentioned method names so that the naming convention follows the DRY principle. Many of the method names were far too long or repetitive or unhelpful in understanding what the method actually completed.


There were many existing test cases for this controller. We have made sure that no test cases were violated by our changes. No changes were made to the views or model.


Testing Details

RSpec

There were already quite a few test cases for the AssignmentsController. We have not added any new tests but made sure that no tests were failing due to our changes. No changes were made to the views and model.