E1908 signupsheet: Difference between revisions
No edit summary |
No edit summary |
||
| Line 27: | Line 27: | ||
=====Drawbacks and Solutions===== | =====Drawbacks and Solutions===== | ||
* '''Problem | * '''Problem 1''': Create method has an if-else condition determining if create or update should be called. Create method should not be responsible for calling update. | ||
:: Identify why the if-else condition exists. The if-else condition exists because the current implementation calls update if a signup sheet with the same name already exists. | |||
* '''Solution''': Rectified this method by removing the call to update and flashing an error instead. | |||
:: | |||
* '''Solution''': | |||
* '''Problem 2''': Update method has a plethora of instance variables defined before updating. These are not necessary (For e.g., look at update method of bookmarks_controller). | |||
* | * '''Solution''': Refactored the variables not needed out. | ||
* | |||
: | |||
* '''Problem 3''': Several method names are renamed to be more intuitive. | |||
* '''Solution''': load_add_signup_topics is renamed to get_assignment_data and ad_info is renamed to get_ad. | |||
* '''Problem 4''': The list method is too long and is sparsely commented. | |||
* '''Solution''': Added comments. | |||
* '''Problem 5''': Participants variable in load_add_signup_topics actually means teams that signed up for a topic. | |||
* '''Solution''': Renamed participants variable to 'teams'. | |||
* '''Problem 6''': Signup_as_instructor_action has if-else ladder. | |||
* '''Solution''': It has been made more elegant using a helper function. | |||
* '''Problem 7''': Delete_signup and delete_signup_as_instructor have much in common and violates the DRY principle. | |||
* '''Solution''': Refactored them by moving the duplicate code to a helper function. | |||
===References=== | ===References=== | ||
#[https://github.com/expertiza/expertiza | #[https://github.com/expertiza/expertiza] | ||
#[http://expertiza.ncsu.edu/ The live Expertiza website] | #[http://expertiza.ncsu.edu/ The live Expertiza website] | ||
Revision as of 01:05, 26 March 2019
E1908. Refactoring the Sign-up sheet Controller
This page provides a description of the Expertiza based OSS project.
About Expertiza
Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.
Problem Statement
The following tasks were accomplished in this project:
- Improved the clarity of code by improving the variable and parameter names.
- Followed naming conventions throughout and renamed methods with inconsistent names including the calling methods.
- Rectified several unwanted if-else conditions in methods and optimized the code.
- Refactored all instance variables and removed unnecessarily defined variables.
- Removed certain unwanted flash messages that occur for some user actions.
- Included comments for functionalities throughout for better understanding.
About Sign-up sheet Controller
Sign-up sheet controller contains all functions related to management of the signup sheet for an assignment function to add new topics to an assignment, edit properties of a particular topic, delete a topic, etc are included here.
Drawbacks and Solutions
- Problem 1: Create method has an if-else condition determining if create or update should be called. Create method should not be responsible for calling update.
- Identify why the if-else condition exists. The if-else condition exists because the current implementation calls update if a signup sheet with the same name already exists.
- Solution: Rectified this method by removing the call to update and flashing an error instead.
- Problem 2: Update method has a plethora of instance variables defined before updating. These are not necessary (For e.g., look at update method of bookmarks_controller).
- Solution: Refactored the variables not needed out.
- Problem 3: Several method names are renamed to be more intuitive.
- Solution: load_add_signup_topics is renamed to get_assignment_data and ad_info is renamed to get_ad.
- Problem 4: The list method is too long and is sparsely commented.
- Solution: Added comments.
- Problem 5: Participants variable in load_add_signup_topics actually means teams that signed up for a topic.
- Solution: Renamed participants variable to 'teams'.
- Problem 6: Signup_as_instructor_action has if-else ladder.
- Solution: It has been made more elegant using a helper function.
- Problem 7: Delete_signup and delete_signup_as_instructor have much in common and violates the DRY principle.
- Solution: Refactored them by moving the duplicate code to a helper function.