CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 56: Line 56:
=== Contributors ===
=== Contributors ===


* Deana Frank
* Deana Franks
* Maday Moya
* Maday Moya
* Jacob Leavitt
* Jacob Leavitt

Revision as of 17:06, 23 March 2024

This wiki page is for information regarding the changes made for the E2415. Reimplementation of responses controller.rb OSS assignment for Spring 2024, CSC/ECE 517.

Introduction

The Expertiza project, an open-source endeavor rooted in Ruby on Rails, embarks on continuous improvement to adapt and integrate modern software engineering practices. A recent initiative under CSC/ECE 517 Spring 2024 - E2415, mentored by Ameya Vaichalkar, focused on the reimagination of the responses_controller.rb. This documentation encapsulates the efforts and methodologies employed in the reimplementation process, aligning with Rails' conventions and enhancing the application's functionality and maintainability.

Reimplementation Objectives

The project's core objectives were manifold, aiming not only to adhere to contemporary Rails naming conventions but also to streamline and refactor the existing ResponseController for better clarity, functionality, and adherence to best practices. Key focus areas included:

  • Naming Conventions: Transitioning to pluralized controller names for consistency with Rails standards.
  • Refactoring for Clarity and Efficiency: Simplifying the overly complex ResponseController by separating concerns and reducing the bulk of non-CRUD operations.
  • Maintaining Robust Security Practices: Retaining up-to-date authentication and authorization methods without modification.
  • Optimizing Code Structure and Logic: Relocating functionalities such as review sorting and reviewer type checks to more appropriate locations within the model or through polymorphism.
  • Streamlining Parameter Setting: Consolidating methods like assign_action_parameters and set_content to ensure efficient access to required objects within the response model.
  • Enhancing Feedback Mechanisms: Keeping the creation of feedback responses within the controller, given its direct relation to Response objects.
  • Standardizing and Optimizing Item Sorting: Reducing redundancy in item sorting calls and aligning terminology with the standard term "item" rather than "question".
  • Simplifying Questionnaire Determination: Refining methods to decide the applicable rubric, survey, or quiz based on the response context.
  • Improving Email Notification System: Moving email generation related to responses to a helper module, thus centralizing and streamlining notification logic.

Solutions and Changes Implemented

The team meticulously tackled each objective, implementing changes that significantly improved the codebase's structure and functionality.

  • Controller Renaming: The controller was renamed to responses_controller.rb, aligning with Rails conventions.
  • Code Refactoring: The controller was streamlined by relocating non-CRUD functionalities to the model or helper modules, such as sorting reviews and checking reviewer types.
  • Authentication and Authorization: These methods were preserved as-is, ensuring the application's security integrity.
  • Functionality Relocation: Sorting reviews was moved to response.helper, and type checks were implemented via polymorphism, eliminating the need for conditional checks in the controller.
  • Parameter Setting Optimization: The set_content method in the response model was enhanced to incorporate the functionalities of assign_action_parameters, simplifying object access.
  • Feedback Creation: The new_feedback functionality was refined to efficiently create and manage Response objects.
  • Item Sorting and Terminology: The term "question" was replaced with "item", and the item sorting logic was optimized to reduce redundancy.
  • Questionnaire Determination Simplification: The method was renamed to get_questionnaire_by_response, with logic simplified for clarity and efficiency.
  • Email Notification Refinement: Email-related methods were consolidated into the ResponseHelper, with new constructs like EmailObject and Mailer introduced for better organization.

Design and Implementation Details

During the reimplementation, the team employed various design patterns and refactoring strategies to achieve a cleaner, more maintainable codebase. Notably, the "Extract Method" pattern played a crucial role in breaking down complex methods into simpler, more understandable components. Additionally, the team focused on reducing cyclomatic complexity by dividing lengthy functions into smaller methods and adopting polymorphism to eliminate conditional checks.

File(s) Modified

  • responses_controller.rb
  • response_helper.rb
  • response_model.rb

Test Plan and Coverage

The project adopted Test-Driven Development (TDD) principles, ensuring that each new feature and refactoring effort was accompanied by comprehensive test cases. This approach not only facilitated the detection of potential issues early in the development cycle but also contributed to a robust and reliable codebase. Test coverage metrics were carefully monitored, with significant improvements observed in both the breadth and depth of the testing suite.

Relevant Links

  • GitHub Repository: Expertiza GitHub
  • Pull Requests: Detailed pull request for the reimplementation can be viewed here.

Team

Mentor

  • Ameya Vaichalkar (ameyav)

Contributors

  • Deana Franks
  • Maday Moya
  • Jacob Leavitt