CSC/ECE 517 Fall 2023 - E2375. Refactor classes relating to signing up for topics

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

When managing sign-ups within expertiza, the evolution of functionality often leads to a need for refactoring existing code. In this case, several classes—sign_up_sheet.rb, sign_up_topic.rb, and signed_up_team.rb—require restructuring to streamline their functionalities and ensure they align with the current project landscape. This refactoring endeavor aims to declutter, reorganize, and enhance code readability and maintainability by removing redundant functionalities and repositioning methods in classes where they serve their intended purposes more explicitly. The end goal is a more coherent and efficient codebase that reflects the current needs of the project while laying the groundwork for future enhancements.

Methods to be refactored

File: sign_up_sheet.rb

Method: (1)self.signup_team

Code smells:

  • Conditional Complexity: There's conditional complexity within the method based on whether users_team is empty or not, leading to slightly repetitive code.
  • Lack of Clear Separation of Concerns: The method handles team creation, sign-up confirmation, and logging within the same block, which might violate the single responsibility principle.
  • Magic Numbers/Variables: users_team[0].t_id uses index 0 directly, assuming there's always at least one entry in users_team.
  • Change method name to Signup_sheet.

What to improve

  • Error Handling: Add error handling for potential failures during team creation or sign-up processes.

Team

Mentor
  • Ed Gehringer
Members
  • Dinesh Pasupuleti <dpasupu@ncsu.edu>
  • Prateek Singamsetty <pksingam@ncsu.edu>
  • Rushabh Shah <rshah32@ncsu.edu>