CSC/ECE 517 Spring 2023 - E2312 + E2313. Reimplement response.rb and responses controller.rb: Difference between revisions
No edit summary |
|||
Line 65: | Line 65: | ||
== Singular convention to Plural convention == | == Singular convention to Plural convention == | ||
There were some | There were some function and classes that followed singular conventions, but were changed to follow plural convention. | ||
== Reducing code == | == Reducing code == |
Revision as of 00:04, 22 March 2023
In order to accommodate issues with another team, our team picked up another member and did both projects. The summaries of the projects are combined here to reflect that.
E2312 Reimplement Response
Summary of Changes
The previous version of response.rb was described as "a mess." The goal of E2312 was to reimplement it to follow better coding standards.
- Made method names clearer, most method names were opaque
- Moved many functionalities to mixins or helper classes to not violate Single-Responsibility
- Reduced usage of class methods
Functionality Moved
This section covers the functionality that was moved out of the response model.
Score Calculation
Score calculation is not inherently tied to the idea of a response. Any object with multiple scores could take advantage of a mixin that provided methods to do calculations on those scores. Functionality for calculating total, average, and maximum scores were all moved to a new Scorable mixin which can be leveraged by other models moving forward.
Emails
The response model provided methods for creating emails. This was moved to a new mixin which can be expanded on to provide email functionality to more models in the future.
Metrics
TODO
Improved Naming
TODO
Testing
TODO
E2313 Reimplement Response Controller
Summary of Changes
The previous version of response_controller.rb was too long. It included too many functions besides the basic CRUD methods. The goal of E2313 was to reimplement it to follow better coding standards.
- Made method name to follow plural convention not singular convention.
- Moved many functionalities to mixins or helper classes
Functionality Moved
This section covers the functionality that was moved out of the responses controller.
Authentication and Authorization
There were authentication and authorization methods in the response controller. These were moved to authorization helper.
Redirect
There was a redirect function that helps redirect by params. It is moved to response helper.
Sort Reviews
There was a functionality to sort reviews. We made new function named sortReviews for doing this stuff and placed it on the response model
Singular convention to Plural convention
There were some function and classes that followed singular conventions, but were changed to follow plural convention.
Reducing code
1
There were multiple methods call to set parameters (assign_action_parameters, set_content). We used before_action so that we reduced the number of call of these methods.
Testing
TODO