CSC/ECE 517 Fall 2013/oss E814 vd: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:
===generate_graph===
===generate_graph===
The first change that can be seen within this method is the extracting of code that adds on to a previous vertex or creates a new one, all based upon the part of speech defined of the tokens encountered while parsing the review.  We called our extracted method tagged_token_check.  BY extracting this method, we were able to reduce duplication (since such similar code occurred four times in the method for tokens that are nouns, adjectives, adverbs, and verbs.  Since the code contained nested if statements, we also were able to reduce the complexity of the method. Screenshots of the code before and after refactoring are included below.  The top picture is the code before refactoring, the middle is the code after, and the bottom is the code within the extracted method.
The first change that can be seen within this method is the extracting of code that adds on to a previous vertex or creates a new one, all based upon the part of speech defined of the tokens encountered while parsing the review.  We called our extracted method tagged_token_check.  BY extracting this method, we were able to reduce duplication (since such similar code occurred four times in the method for tokens that are nouns, adjectives, adverbs, and verbs.  Since the code contained nested if statements, we also were able to reduce the complexity of the method. Screenshots of the code before and after refactoring are included below.  The top picture is the code before refactoring, the middle is the code after, and the bottom is the code within the extracted method.
 
[[File:Tagged token check 0.PNG|thumb|method before refactoring]]
[[File:Tagged token check 1.PNG|thumb|method after refactoring]]
[[File:Tagged token check 2.PNG|thumb|method after refactoring]]
==References==
==References==

Revision as of 19:53, 30 October 2013

Expertiza is a web application that supports peer-review for a variety of entities. As it is still evolving, expertiza has several areas that require work. Among these include areas that require refactoring existing code to improve code quality. The graph_generator.rb file is one such area. This write-up describes our refactoring decisions for this file.

Background

Resources

Changes by Method

generate_graph

The first change that can be seen within this method is the extracting of code that adds on to a previous vertex or creates a new one, all based upon the part of speech defined of the tokens encountered while parsing the review. We called our extracted method tagged_token_check. BY extracting this method, we were able to reduce duplication (since such similar code occurred four times in the method for tokens that are nouns, adjectives, adverbs, and verbs. Since the code contained nested if statements, we also were able to reduce the complexity of the method. Screenshots of the code before and after refactoring are included below. The top picture is the code before refactoring, the middle is the code after, and the bottom is the code within the extracted method.

method before refactoring
method after refactoring
File:Tagged token check 2.PNG
method after refactoring

References