CSC/ECE 517 Fall 2013/oss aoa: Difference between revisions
Line 41: | Line 41: | ||
:1. function candidate_topics_to_review | :1. function candidate_topics_to_review | ||
Code before Refactoring: | |||
<pre> | <pre> | ||
contributor_set.reject! { |contributor| signed_up_topic(contributor).nil? or !contributor.has_submissions? } | |||
# Reject contributions of topics whose deadline has passed | |||
contributor_set.reject! { |contributor| contributor.assignment.get_current_stage(signed_up_topic(contributor).id) == 'Complete' or | |||
contributor.assignment.get_current_stage(signed_up_topic(contributor).id) == 'submission' } | |||
</pre> | </pre> | ||
Revision as of 05:16, 30 October 2013
OSS Project E 819 - Refactoring and Testing - Assignment
This Wiki page provides a detailed description of the Open Source Software project conducted on Expertiza, as part of the Object Oriented Languages and Systems coursework.
Introduction to Expertiza
Expertizais an open source project built using the Ruby on Rails platform. It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from github and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image "Ruby on Rails". If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.
Overview of project
The main objective of the project was to refactor three Ruby files:
- • assignment.rb (925 lines)
- • assignment_participant.rb (385 lines)
- • assignment_team.rb (254 lines)
These three files are responsible for creation and management of assignments in Expertiza. They perform operations relating to a user participating in an assignment. AssignmentParticipant is a subclass of class Participant. CourseParticipant is Participant’s only other subclass. If a course has CourseParticipants, then an assignment can take its participants from the CourseParticipants.
Project Requirements
- 1. Do methods 'get_percentage_reviews_completed' and 'get_total_reviews_completed_by_type_and_date' belong to this class? The assignment.rb file should only contain those methods that pertain to the creation and maintenance of assignments in Expertiza.
- 2. The self.export method contains a lot of statements that have been repeated. Refactor this method to avoid duplication.
- 3. Look for other methods in the assignment.rb file that shouldn't belong to this file but to some other model/controller.
- 4. The 'get_scores' method in the 'assignment', 'assignment_participant' and 'assignment_team' files contain lines of code that appear to be repeated. Can this be refactored so that only one method implements the common functionality?
- 5. Refactor 'get_hyperlinks' to replace the conditional statement with polymorphism.
- 6. Refactor the 'get_reviews' method by replacing the conditional statement with polymorphism.
- 7. Look for any unused methods or variables in these files.
- 8. Also apply other refactorings such as Rename variable, Rename method to give the variables and methods more meaningful names.
Design Changes (Refactoring) Performed
Describe all refactorings done in detail along with code snippets.
Following are the code snippets of all the files that have been refactored as part of the project:
Refactoring done in assignment.rb
- 1. function candidate_topics_to_review
Code before Refactoring:
contributor_set.reject! { |contributor| signed_up_topic(contributor).nil? or !contributor.has_submissions? } # Reject contributions of topics whose deadline has passed contributor_set.reject! { |contributor| contributor.assignment.get_current_stage(signed_up_topic(contributor).id) == 'Complete' or contributor.assignment.get_current_stage(signed_up_topic(contributor).id) == 'submission' }