CSC/ECE 517 Spring 2023 - E2338. Reimplement the response map hierarchy

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

Expertiza Background

When someone writes a review in Expertiza, they are creating an instance of the Response class. Each Response is created based on a particular ResponseMap. The ResponseMap tells who the reviewer is (the reviewer_id), who the reviewee is (the reviewee_id), and what is being reviewed (the reviewed_object_id).

  • The reviewer_id is normally a record in the Participants table, which specifies an AssignmentParticipant. However, if teams rather than individuals are doing reviews for this assignment, it may be an AssignmentTeam.
  • For reviews of student work, the reviewee_id is always an AssignmentTeam. (If an assignment is set up so individuals rather than teams submit work, the reviewee will still be a 1-member AssignmentTeam.)
  • For teammate reviews, the reviewee_id is always an AssignmentParticipant.
  • The reviewed_object_id is normally an Assignment. But in the case of meta-reviews, the reviewed_object_id is another ResponseMap (because it is a review that is being reviewed).

Problem Statement

We are refactoring the code which are being implemented previously for Re-implementation of response map hierarchy (E2314[[1]]). Some of the changes which are being pointed out till now are as follows-

  • In the previous re-implementation, some of the methods are defined in class level which can be modified to instance level methods for better functionality and adhering to the Object Oriented Design principles.
  • Few of the methods are also present in the existing project which should be implemented in other classes according to their functionality and for increasing coherency of the classes.
  • Some of the methods also needs to be renamed in this refactoring process for better understanding of the developers who will be working on the project later on.

The detailed problem statement is as follows:-

1. The function show_review inside feedback_response_map.rb file needs to be removed as reviews belongs to a response_map and hence one response_map can have lot of reviews. For showing each reviews present in the response_map, the map object can be iterated in the controller class.

2. Accordingly, the relation between the Review class and the Response_map class needs to be changed. The relationship is wrongly set as review has a response_map, which needs to be changed to response_map has many reviews.

3. The name of the method questionnaires is more localized in nature and it should be changed to “author_feedback_questionnaire” which will provide better understanding for the functionality of the method. Also it should be checked that if this method is required at all as author_feedback_questionnaire can be extracted from the Database directly very easily and whether this should be put into a separate method or not.

4. A method named "latest_feedback" which is present in the existing code should be removed from the feedback_response_map.rb class. Instead a method can be added to return a particular feedback according to the review_id which will reduce unnecessary data being provided to the user of this method.

5. The scoring class should be included with the "response_map" class so that it can add methods only to an instance of a class other than adding methods to the class.

6. Remove few of the methods from response_map.rb which are not relevant and should instead be used in the controller class.

7. Throughout the project, polymorphism needs to be implemented in some of the places where if-else are being used to make the design adhere to Object Oriented Programming.

8. There is a questionnaire method implemented in each sub class where the "reviewer" or "reviewee" is assigned. This functionality can be implemented in the super class and assign the value based on the class name.

9. title method is implemented to uniquely identify the response_maps belonging to that sub class. Reimplement this in the super class.

10. The email method is written in each subclass to suit the response locally. Visitor Pattern can be used here to attach the functionality rather than making it a part of each subclass.

11. The after_initialize function present in review_response_map.rb allows a team to review rather than individuals if needed. Verify if any database normalization principles are violated and take a decision on reimplementing it.

12. The method responses_for_team_round in review_response_map.rb is returning a data structure that contains responses from all the rounds. Reimplement it so that the calling function queries for a specific round and only one response is returned rather than the complete data structure.

Implementation

Flowchart

Refactoring

Refactoring method

Function placed in the view as partials

Testing

RSpec Testing

Manual Testing

Design Pattern

A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.

During the process of refactoring methods as well as method names,Strategy Pattern was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request. We may implement some more design patterns which we think might be necessary while refactoring the project.

References

Team Members