CSC/ECE 517 Fall 2013/oss ssv

From Expertiza_Wiki
Revision as of 04:42, 30 October 2013 by Skhare (talk | contribs) (→‎New Design)
Jump to navigation Jump to search

E813. Refactoring and testing — degree_of_relevance.rb

Introduction

The class degree_of_relevance.rb is used to how relevant one piece of text is to another piece of text. It is used to evaluate the relevance between the submitted work and review(or metareview) for an assignment. It is important to evaluate the reviews for a submitted work to ensure that if the review is not relevant to the submission, it is considered to be invalid and does not impact student's grade. This class contains a lot of duplicated code and has long and complex methods. It has been assigned grade "F", according to metric like code complexity, duplication, lines of code per method etc. Since this class is important for the research on expertiza, it should be re-factored to reduce its complexity, duplication and introduce coding best practices. Our task for this project is to re-factor this class and test it thoroughly.

Existing Design

Implementation

New Design and Refactoring

New Design

We have taken ideas from the Template design pattern to improve the design of the class. Although we did not directly implement this design pattern on the class, the idea of defining a skeleton of an algorithm in one class, and defering some steps to subclasses, allowed us to come up with a similar design which segregates different functionality to different classes. The following is a brief outline of the changes made:

  • Divided the code into 4 classes to segregate the functionality making a logical separation of code.
  • These classes are -
    • compare_graph_edges.rb
    • compare_graph_svo_edges.rb
    • compare_graph_vertices.rb
    • degree_of_relevance.rb
  • Extracted common code in methods that be re-used.
  • After refactoring the grade according to codeclimate for the class is "C".

How to run the code

Testing

Conclusion

References