CSC/ECE 517 Fall 2014/OSS E1452 slj: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
   
   
'''Classes:'''
'''Classes:'''
* AssignmentTeam.rb
* assignment_team.rb
* CourseTeam.rb
* course_team.rb
* Team.rb
* team.rb


'''What they do:'''
'''What they do:'''

Revision as of 02:02, 31 October 2014

E1452: Refactoring AssignmentTeam and CourseTeam models

The requirements provided for the Open Source System project of Expertiza were as follows:

Classes:

  • assignment_team.rb
  • course_team.rb
  • team.rb

What they do: The AssignmentTeam model checks whether a team has participants for an assignment, whether a topic has been picked by the team and reviews has be given for a particular team and adds, deletes and retrieves participants in a team. The CourseTeam model gives the paticipants in a course and allows to add and delete participants in a course. This is for the use by the instructor.

What is needed: Check if we need two methods participant and get_participant as they may be similar. If so, refactor to make one method. Rename create_team_and_node method as create method (follow Ruby style) Rename includes? method to has_participant? Remove duplicate code from these 2 sublcasses of Team. Assignment_Team class too long (235 lines)

Introduction

The AssignmentTeam and CourseTeam models, as sibling subclasses of the Team model, tended to share certain functionality. This assignment called for refactoring those classes to make them better conform to ruby convention and to support the DRY ("Don't Repeat Yourself") principle of avoiding duplicate code.

A quick skim of the code turned up a few places where the AssignmentTeam and CourseTeam models had similar functionality, as well as multiple methods and variables that needed better names. Some preliminary suggestions were run past the point of contact for this section of the codebase. They are summarized as follows:

  • The 'participants' and 'get_participants' methods in AssignmentTeam appear to have the same functionality, so these should be refactored into a single method.
  • The 'create_team_and_node' method will be renamed to 'create' to better follow accepted Ruby conventions.
    • A few other methods that could also be named better. For example, 'remove_team_by_id(id)' could be 'delete(id)'.
  • The 'includes?' method will be renamed to 'has_participant?'
  • There are some common responsibilities in both AssignmentTeam and CourseTeam, so that code will be pushed up into the superclass Team.

Project Design and Approach

UML Class Diagram

Team Model: Team.rb

AssignmentTeam Model: AssignmentTeam.rb

CourseTeam Model: CourseTeam.rb

Scope for future work

Conclusion

References

See Also