File:ScreenShotOODD.png

From Expertiza_Wiki
Jump to navigation Jump to search

Original file(940 × 410 pixels, file size: 81 KB, MIME type: image/png)

E1463: Refactoring TreeDisplayController

Project Links

Github Repo
Expertize Pull Request
Travis CI Test Cases Passes


Setup - How To View Our Expertiza Fork Running on AWS

NOTE: The scope of our project was only to refactor select code. There are no feature additions or changes, so it should work just like production Expertiza.

1) Go to our Expertiza project running on AWS

2) Login as Admin
User: user2
Password: password

3) Click on "Manage..." if you are not automatically directed to the tree display.

Project Description

For this project, our team refactored the TreeDisplayController class in the Expertiza OSS project. This class provides access to questionnaires, review rubrics, author feedback, courses, assignments, and course evaluations. The tree display lists all of these categories with the ability for the user to "drill down" into the subcategories or just expand/collapse as needed.

Refactoring TreeDisplayController Issues

As part of the refactoring task, we had to resolve the following issues for enhancing code readability and maintainability. The tasks included:

  1. Similar code found in other locations.
  2. Cyclomatic and Perceived complexity for get_children_node_ng is too high.
  3. Useless assignment to variable - `childNodes`.
  4. Use snake_case for variable names.
  5. Prefer `each` over `for`.
  6. The use of `eval` is a serious security risk.
  7. Avoid the use of the case equality operator `===`.
  8. Line is too long.
  9. `end` at 334, 2 is not aligned with `class` at 1, 0.

1) Similar code found in other locations

In order to make the codebase more RESTful, we have replaced all the controller action redirections with a tree_display_index_path which enormously reduces the code content and as well as provides an organized approach to action redirections.

Changed to ⇒

2) Cyclomatic and Perceived complexity for get_children_node_ng is too high

By creating two separate functions child_nodes_from_params and initialize_fnode_update_children, the complexity for this function was reduced. The initialize_fnode_update_children function was in-turn sub-functioned into update_fnode_children which updated the children nodes. The new function looks like this:

3) Useless assignment to variable - `childNodes` were removed from following two places.

4) Use snake_case for variable names.

Variable names using camelCase were renamed to use snake_case as according to ruby coding guidelines.


5) Prefer `each` over `for`

6)The use of `eval` is a serious security risk.

7) Avoid the use of the case equality operator `===`.

has been changed to ⇒

8) Line is too long.

Future Considerations

Conclusion

In conclusion, we were able to successfully refactor the tree_display_controller and related controllers and views. We improved and expanded the use of RESTful and DRY design choices, implemented the use of routing helpers, ensured that instantiation of instance variables is minimized, and overall improved the quality and efficiency of the Expertiza codebase. We also discovered a number of potential issues and additional areas for improvement.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current21:01, 28 October 2016Thumbnail for version as of 21:01, 28 October 2016940 × 410 (81 KB)Bkasliw (talk | contribs)

There are no pages that use this file.