<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Abhutan</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Abhutan"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Abhutan"/>
	<updated>2026-07-14T05:47:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82150</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82150"/>
		<updated>2013-10-31T03:17:22Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
[https://github.com/abhutan/expertiza GitHub Project Repository]&lt;br /&gt;
&lt;br /&gt;
[http://152.7.99.160:3000/ VCL IP Address]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Wiki]&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage -&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage -&amp;gt; Assignments and hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:NonstaggeredAddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82149</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82149"/>
		<updated>2013-10-31T03:16:35Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
[https://github.com/abhutan/expertiza GitHub Project Repository]&lt;br /&gt;
&lt;br /&gt;
[http://152.7.99.160:3000/ VCL IP Address]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Wiki]&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage -&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage -&amp;gt; Assignments and hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:NonstaggeredAddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png|200px]]&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82147</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82147"/>
		<updated>2013-10-31T03:15:55Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
[https://github.com/abhutan/expertiza GitHub Project Repository]&lt;br /&gt;
&lt;br /&gt;
[http://152.7.99.160:3000/ VCL IP Address]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Wiki]&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage -&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage -&amp;gt; Assignments and hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:NonstaggeredAddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]200px&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:NonstaggeredAddTopic.png&amp;diff=82144</id>
		<title>File:NonstaggeredAddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:NonstaggeredAddTopic.png&amp;diff=82144"/>
		<updated>2013-10-31T03:14:45Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82142</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82142"/>
		<updated>2013-10-31T03:13:43Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
[https://github.com/abhutan/expertiza GitHub Project Repository]&lt;br /&gt;
&lt;br /&gt;
[http://152.7.99.160:3000/ VCL IP Address]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Wiki]&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage -&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage -&amp;gt; Assignments and hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82137</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82137"/>
		<updated>2013-10-31T03:13:14Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage Assignments and hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82135</id>
		<title>File:AddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82135"/>
		<updated>2013-10-31T03:12:35Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:AddTopic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82132</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82132"/>
		<updated>2013-10-31T03:10:47Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions. &lt;br /&gt;
&lt;br /&gt;
Additionally, project required removal of redundant and dead code which enhances code readability and optimizes code performance.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. We have made a single method call and condition check in various files ,for type of assignment, has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage Assignments and Hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:NodueDate.png&amp;diff=82122</id>
		<title>File:NodueDate.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:NodueDate.png&amp;diff=82122"/>
		<updated>2013-10-31T03:07:41Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:NodueDate.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ShowdueDate.png&amp;diff=82120</id>
		<title>File:ShowdueDate.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ShowdueDate.png&amp;diff=82120"/>
		<updated>2013-10-31T03:07:17Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:ShowdueDate.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82118</id>
		<title>File:AddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82118"/>
		<updated>2013-10-31T03:06:50Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:AddTopic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82114</id>
		<title>File:AddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82114"/>
		<updated>2013-10-31T03:06:14Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:AddTopic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82087</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82087"/>
		<updated>2013-10-31T02:52:21Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
[[File:AddTopic.png]]&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
[[File:ShowdueDate.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage Assignments and Hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
[[File:NodueDate.png]]&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:NodueDate.png&amp;diff=82083</id>
		<title>File:NodueDate.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:NodueDate.png&amp;diff=82083"/>
		<updated>2013-10-31T02:51:43Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ShowdueDate.png&amp;diff=82072</id>
		<title>File:ShowdueDate.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ShowdueDate.png&amp;diff=82072"/>
		<updated>2013-10-31T02:48:32Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82055</id>
		<title>File:AddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82055"/>
		<updated>2013-10-31T02:46:03Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: uploaded a new version of &amp;amp;quot;File:AddTopic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82052</id>
		<title>File:AddTopic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AddTopic.png&amp;diff=82052"/>
		<updated>2013-10-31T02:44:56Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82043</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82043"/>
		<updated>2013-10-31T02:41:09Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
'''Introduction to Expertiza'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
6. Now to view the difference between the Stagerred and Non-Staggered Deadlines, follow steps.&lt;br /&gt;
&lt;br /&gt;
7. Go to Manage Assignments and Hover over “SALT Demo” and click on “Edit  Signup sheet”.&lt;br /&gt;
&lt;br /&gt;
8. Click on “New Topic” and fill in the details for a new topic.&lt;br /&gt;
&lt;br /&gt;
9. Now you will be able to see that there is no option for “Show Start/Due Date” which is because of the reason that this is not a staggered assignment.&lt;br /&gt;
&lt;br /&gt;
10. Hence there is only one due date and has no dependencies on others.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82035</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82035"/>
		<updated>2013-10-31T02:38:20Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”.&lt;br /&gt;
&lt;br /&gt;
2. Click on “New Topic”.&lt;br /&gt;
&lt;br /&gt;
3. Enter the details of the topic you want to create. Create at least 2 topics for better analysis of the project.&lt;br /&gt;
&lt;br /&gt;
4. Now once you have created two new topics , then Click on  “Show start/due date”.&lt;br /&gt;
&lt;br /&gt;
5. You should be able to view the new start and due dates of your topics confirming these are the staggered deadlines for “StaggeredDeadlines_Refactoring” which has many topics with different deadlines.&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82031</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82031"/>
		<updated>2013-10-31T02:36:22Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''=E810 Regularize staggered-deadline assignments='''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82029</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82029"/>
		<updated>2013-10-31T02:36:09Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Steps to verify changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E810 Regularize staggered-deadline assignments'''&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
Log into the application with the user having instructor's role or super user's role.&lt;br /&gt;
1. Go to Manage-&amp;gt; Assignments and hover over the assignment “StaggeredDeadlines_Refactoring”&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82016</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=82016"/>
		<updated>2013-10-31T02:30:35Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it introduced code smells. So it was checked if there was any reference to this code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Before Changes to Code===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
=Steps to verify changes=&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;br /&gt;
&lt;br /&gt;
In current implementation, our database has two tables for staggered and non-staggered deadlines. For any future improvements, we can make use of STI (Single Table Inheritance) and analyze if applying STI would really impact query performance when application runs and extracts data from database.&lt;br /&gt;
&lt;br /&gt;
= Concise Report on Refactoring =&lt;br /&gt;
&lt;br /&gt;
The project had redundant code, multiple functionalities in a method and extra conditional statements in controller, model and view files. We analyzed each occurrence of these issues, thus creating a list which needed to be refactored. Controllers like sign_up_sheet_controler, assignment.rb, due_date.rb,deadline_types.rb along with other files were modified. It's very difficult to explain the sequential and detailed procedure, but it has been explained in the sections above within the capacity of the Wiki.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81940</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81940"/>
		<updated>2013-10-31T01:58:27Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Current Scenario */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
The local variables topic_set and topic under the staggered deadline check statement were never used in the entire scope of the project , it made the code smelly. So it was checked if there was any reference to this smelly code, and upon discovering it was not used anywhere, we decided to eliminate this code.&lt;br /&gt;
 &lt;br /&gt;
===Before Changes to Code===&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
 &lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81929</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81929"/>
		<updated>2013-10-31T01:56:55Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* After changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;assignment.rb&amp;lt;/b&amp;gt; model&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; defined in &amp;lt;b&amp;gt;topic_deadline.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_next_due_date&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;due_date.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in &amp;lt;b&amp;gt;deadline_type.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81926</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81926"/>
		<updated>2013-10-31T01:55:31Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* After changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New find_next_due_date defined in topic_deadline.rb:&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New find_next_due_date method defined in due_date.rb&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New &amp;lt;b&amp;gt;find_drop_topic_deadline_id&amp;lt;/b&amp;gt; method defined in deadline_type.rb&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81921</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81921"/>
		<updated>2013-10-31T01:54:34Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    ....&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    ....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       ....&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New find_next_due_date defined in topic_deadline.rb:&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New find_next_due_date in due_date.rb&lt;br /&gt;
&lt;br /&gt;
 def self.find_next_due_date(assignment_id&lt;br /&gt;
   drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
   DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                assignment_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
New find_drop_topic_deadline_id method in deadline_type.rb&lt;br /&gt;
&lt;br /&gt;
 def self.find_drop_topic_deadline_id()&lt;br /&gt;
   DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    .....&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    .....&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81904</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81904"/>
		<updated>2013-10-31T01:51:21Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* After changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
topic_deadline.rb:&lt;br /&gt;
 def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
    drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
    if topic_id&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    else&lt;br /&gt;
      TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                         assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    assignment_id = params[:id]&lt;br /&gt;
    @sign_up_topic = SignUpTopic.new&lt;br /&gt;
    @sign_up_topic.topic_identifier = 'MT1'&lt;br /&gt;
    @sign_up_topic.topic_name = 'Microtask Topic'&lt;br /&gt;
 &lt;br /&gt;
    @sign_up_topic.max_choosers = '0'&lt;br /&gt;
    @sign_up_topic.micropayment = 0&lt;br /&gt;
    @sign_up_topic.assignment_id = assignment_id&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
    if @sign_up_topic.save&lt;br /&gt;
      flash[:notice] = 'Default Microtask topic was created - please update.'&lt;br /&gt;
      redirect_to_sign_up(assignment_id)&lt;br /&gt;
    else&lt;br /&gt;
      render :action =&amp;gt; 'new', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81900</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81900"/>
		<updated>2013-10-31T01:50:51Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in various views.&lt;br /&gt;
For instance, for view _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
topic_deadline.rb:&lt;br /&gt;
  def self.find_next_due_date(topic_id,assignment_id)&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_drop_topic_deadline_id()&lt;br /&gt;
     if topic_id&lt;br /&gt;
       TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                          topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
     else&lt;br /&gt;
       TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                          assignment_id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
     end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    assignment_id = params[:id]&lt;br /&gt;
    @sign_up_topic = SignUpTopic.new&lt;br /&gt;
    @sign_up_topic.topic_identifier = 'MT1'&lt;br /&gt;
    @sign_up_topic.topic_name = 'Microtask Topic'&lt;br /&gt;
 &lt;br /&gt;
    @sign_up_topic.max_choosers = '0'&lt;br /&gt;
    @sign_up_topic.micropayment = 0&lt;br /&gt;
    @sign_up_topic.assignment_id = assignment_id&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
  &lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
    end&lt;br /&gt;
                                                                                                                                                                  if @sign_up_topic.save&lt;br /&gt;
      flash[:notice] = 'Default Microtask topic was created - please update.'&lt;br /&gt;
      redirect_to_sign_up(assignment_id)&lt;br /&gt;
    else&lt;br /&gt;
      render :action =&amp;gt; 'new', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81889</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81889"/>
		<updated>2013-10-31T01:48:36Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in views like _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% &amp;lt;b&amp;gt;if @assignment.staggered_deadline == true&amp;lt;/b&amp;gt; %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics_staggered'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% else %&amp;gt;&lt;br /&gt;
    &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
  &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), &lt;br /&gt;
      {:controller =&amp;gt; 'sign_up_sheet', &amp;lt;b&amp;gt;:action =&amp;gt; 'add_signup_topics'&amp;lt;/b&amp;gt;, :id =&amp;gt; node.node_object_id}, &lt;br /&gt;
      {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Before Changes to code===&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes to Code===&lt;br /&gt;
&lt;br /&gt;
The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = TopicDeadline.find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = DueDate.find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
 def create_default_for_microtask&lt;br /&gt;
    assignment_id = params[:id]&lt;br /&gt;
    @sign_up_topic = SignUpTopic.new&lt;br /&gt;
    @sign_up_topic.topic_identifier = 'MT1'&lt;br /&gt;
    @sign_up_topic.topic_name = 'Microtask Topic'&lt;br /&gt;
    @sign_up_topic.max_choosers = '0'&lt;br /&gt;
    @sign_up_topic.micropayment = 0&lt;br /&gt;
    @sign_up_topic.assignment_id = assignment_id&lt;br /&gt;
&lt;br /&gt;
    @assignment = Assignment.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      topic_set = Array.new&lt;br /&gt;
      topic = @sign_up_topic.id&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if @sign_up_topic.save&lt;br /&gt;
&lt;br /&gt;
      flash[:notice] = 'Default Microtask topic was created - please update.'&lt;br /&gt;
      redirect_to_sign_up(assignment_id)&lt;br /&gt;
    else&lt;br /&gt;
      render :action =&amp;gt; 'new', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81864</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81864"/>
		<updated>2013-10-31T01:42:49Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* After changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
We had to make conditional check every time the function is called for the assignment type. For instance, below method redirects to the /add_signup_topics or the /add_signup_topics_staggered page depending on assignment type &lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Similarly the method call is re-factored in views like _assignments_actions.html.erb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Changes&amp;lt;b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;% if @assignment.staggered_deadline == true %&amp;gt;&lt;br /&gt;
 -                      &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), {:controller =&amp;gt; 'sign_up_sheet', :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; node.node_object_id}, {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 -                  &amp;lt;% else %&amp;gt;&lt;br /&gt;
 +&lt;br /&gt;
                        &amp;lt;%= link_to image_tag('/images/tree_view/edit-signup-sheet-24.png', :title =&amp;gt; 'Edit signup sheet'), {:controller =&amp;gt; 'sign_up_sheet', :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; node.node_object_id}, {:title =&amp;gt; 'Edit signup sheet'} %&amp;gt;&lt;br /&gt;
 -                  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
Before Changes to code&lt;br /&gt;
&lt;br /&gt;
The add_signup_topics , calculated due dates for separate topics for a Staggered assignment with individual Topic deadlines.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Changes to Code&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
 and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;#Function call to set up due dates&lt;br /&gt;
      assignment_due_date&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
     #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the new code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
assignment.rb model:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81827</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81827"/>
		<updated>2013-10-31T01:34:46Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* After changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
[b]Before Changes to code&lt;br /&gt;
The add_signup_topics , made a call to load_add_signup_topics method followed by a check for staggered assignments and calculation of due   &lt;br /&gt;
dates for separate topics in this Staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
[b] After Changes to Code&lt;br /&gt;
 The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
 and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   #Function call to set up due dates&lt;br /&gt;
      assignment_due_date&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
       #Use this until you figure out how to initialize this array&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
  &lt;br /&gt;
   if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
       .......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
   next_due_date = find_next_due_date(topic_id,self.id)&lt;br /&gt;
 else&lt;br /&gt;
   next_due_date = find_next_due_date(self.id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81825</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81825"/>
		<updated>2013-10-31T01:34:23Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Conditional call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 def redirect_to_sign_up(assignment_id)&lt;br /&gt;
    assignment = Assignment.find(assignment_id)&lt;br /&gt;
    if assignment.staggered_deadline == true&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics_staggered', :id =&amp;gt; assignment_id&lt;br /&gt;
    else&lt;br /&gt;
      redirect_to :action =&amp;gt; 'add_signup_topics', :id =&amp;gt; assignment_id&lt;br /&gt;
    end&lt;br /&gt;
 end&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Single method call&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check in various files for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
Improved Readability by extracting two separate functionalities from the same method into separate methods with appropriate naming convention and responsibilities.&lt;br /&gt;
&lt;br /&gt;
[b]Before Changes to code&lt;br /&gt;
The add_signup_topics , made a call to load_add_signup_topics method followed by a check for staggered assignments and calculation of due   &lt;br /&gt;
dates for separate topics in this Staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
[b] After Changes to Code&lt;br /&gt;
 The logic to calculate due_dates was moved to a separate method called assignment_due_date , as this is only valid for staggered assignments   &lt;br /&gt;
 and hence it should be placed in a different method instead of merging it the add_signup_topics&lt;br /&gt;
 &lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
     &lt;br /&gt;
   #Function call to set up due dates&lt;br /&gt;
      assignment_due_date&lt;br /&gt;
      &lt;br /&gt;
   #Render a view different from the add_sign_up.html.erb  , so rendering a view for staggered deadlines.&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def assignment_due_date&lt;br /&gt;
       #Use this until you figure out how to initialize this array&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
  &lt;br /&gt;
   if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
       .......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==Case 3 : Modularize Code in application.rb==&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===After changes===&lt;br /&gt;
The database queries have been moved to their respective models. The queries to TopicDeadline table, DueDate table and DeadlineType table have been moved to their models. Below is the code in assignments.rb model which calls TopicDeadline.rb, DueDate.rb and DeadlineType.rb respectively for the queries in their tables:&lt;br /&gt;
&lt;br /&gt;
 if self.staggered_deadline?&lt;br /&gt;
  next_due_date = find_next_due_date(topic_id,self.id)&lt;br /&gt;
else&lt;br /&gt;
  next_due_date = find_next_due_date(self.id)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81804</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81804"/>
		<updated>2013-10-31T01:26:13Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check at various places for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      &lt;br /&gt;
      if topic_id&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        &lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81801</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81801"/>
		<updated>2013-10-31T01:25:34Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check at various places for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      # next_due_date - the nearest due date that hasn't passed&lt;br /&gt;
      if topic_id&lt;br /&gt;
        # next for topic&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                   topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        # next for assignment&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                                  self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81799</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81799"/>
		<updated>2013-10-31T01:25:05Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
At several places in the project, there was separate method call based on staggered and non-staggered assignments. Now there is a single method call and condition check at various places for type of assignment has been removed as part of re-factoring.&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      # next_due_date - the nearest due date that hasn't passed&lt;br /&gt;
      if topic_id&lt;br /&gt;
        # next for topic&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                        topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        # next for assignment&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                        self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
                      self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81796</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81796"/>
		<updated>2013-10-31T01:24:26Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      # next_due_date - the nearest due date that hasn't passed&lt;br /&gt;
      if topic_id&lt;br /&gt;
        # next for topic&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        # next for assignment&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', &lt;br /&gt;
self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81793</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81793"/>
		<updated>2013-10-31T01:23:36Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
   load_add_signup_topics(params[:id])&lt;br /&gt;
   if @assignment.staggered_deadline ==true&lt;br /&gt;
      @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
      @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
      &lt;br /&gt;
      #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
      @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
      if !@topics.nil?&lt;br /&gt;
        i=0&lt;br /&gt;
        @topics.each { |topic|&lt;br /&gt;
        ......&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
      render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
     drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
    if self.staggered_deadline?&lt;br /&gt;
      # next_due_date - the nearest due date that hasn't passed&lt;br /&gt;
      if topic_id&lt;br /&gt;
        # next for topic&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        # next for assignment&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81790</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81790"/>
		<updated>2013-10-31T01:20:40Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
       @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
       if !@topics.nil?&lt;br /&gt;
         i=0&lt;br /&gt;
         @topics.each { |topic|&lt;br /&gt;
         ......&lt;br /&gt;
         i = i + 1&lt;br /&gt;
       end&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
                                                                                                                                                                &lt;br /&gt;
  #Use this until you figure out how to initialize this array&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
     if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
           .....&lt;br /&gt;
                                                                                                                                                                                                                                             &lt;br /&gt;
     @duedates[i]['submission_'+ (@review_rounds+1).to_s] = DateTime.parse(duedate_subm['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
        else&lt;br /&gt;
          @duedates[i]['submission_'+ (@review_rounds+1).to_s] = nil&lt;br /&gt;
     end&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has the logic to find the nearest due date that hasn't passed.&lt;br /&gt;
&lt;br /&gt;
 drop_topic_deadline_id = DeadlineType.find_by_name('drop_topic').id&lt;br /&gt;
      if self.staggered_deadline?&lt;br /&gt;
&lt;br /&gt;
      if topic_id&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['topic_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', topic_id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
      else&lt;br /&gt;
        next_due_date = TopicDeadline.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', self.id, Time.now, drop_topic_deadline_id], :joins =&amp;gt; {:topic =&amp;gt; :assignment}, :order =&amp;gt; 'due_at')&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      next_due_date = DueDate.find(:first, :conditions =&amp;gt; ['assignment_id = ? and due_at &amp;gt;= ? and deadline_type_id &amp;lt;&amp;gt; ?', self.id, Time.now, drop_topic_deadline_id], :order =&amp;gt; 'due_at')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81780</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81780"/>
		<updated>2013-10-31T01:16:13Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Case 3 : Modularize Code in application.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on Remote Servers and Wiki submissions. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics_staggered&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This method lists all the available topics for an assignment and allows admin to set due dates for assignment.Staggered means that different topics can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
    &lt;br /&gt;
    #below functionality finds allows to set due dates for topics of assignment&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
      ......&lt;br /&gt;
      i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;method:add_signup_topics&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
It is similar to the above function except that all the topics and review/submission rounds have the similar deadlines.&lt;br /&gt;
  def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===After Changes===&lt;br /&gt;
We have redundant code in two methods so we merged add_signup_topics_staggered and add_signup_topics into add_signup_topics. The action calls single method for both type of assignments and renders views based on condition of staggered or non-staggered assignment.&lt;br /&gt;
&lt;br /&gt;
 def add_signup_topics&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
    if @assignment.staggered_deadline ==true&lt;br /&gt;
       @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
       @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
       &lt;br /&gt;
       #Function call to set up due dates&lt;br /&gt;
       assignment_due_date&lt;br /&gt;
       &lt;br /&gt;
       #Render a view different for staggered deadlines assignment from the add_sign_up.html.erb&lt;br /&gt;
       render &amp;quot;add_signup_topics_staggered&amp;quot;&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
In the assignment.rb model, there exists one method(check_condition) which checks whether review, meta-review, etc are allowed or not. This method makes database calls to TopicDeadline table, DueDate and DeadlineType tables. The database queries have been moved to their respective models. Following is the code which was existing before the changes were made. It has&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81682</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81682"/>
		<updated>2013-10-31T00:22:32Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Introduction to Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It supports peer review, team assignments and submission of projects using any method like URL, wiki page or even code. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github]. This application provides the efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large. &lt;br /&gt;
&lt;br /&gt;
Expertiza is supported by National Science Foundation under Grant No. 0536558. Additional funding from the NCSU Learning in a Technology-Rich Environment (LITRE) program, the NCSU Faculty Center for Teaching and Learning, the NCSU STEM Initiative, and the Center for Advanced Computing and Communication.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
On the other hand, If Assignment A has Topic A and Topic B, but they all have the same deadlines i.e. there is no dependency on each other then that's Normal Due Date scenario. In this case an Assignment may or may not have separate Topics.&lt;br /&gt;
&lt;br /&gt;
Original code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
Different method definitions for setting up staggered and non-staggered assignment sign up sheet.&lt;br /&gt;
&lt;br /&gt;
##This displays a page that lists all the available topics for an assignment.&lt;br /&gt;
  #Contains links that let an admin or Instructor edit, delete, view enrolled/waitlisted members for each topic&lt;br /&gt;
  #Also contains links to delete topics and modify the deadlines for individual topics. Staggered means that different topics&lt;br /&gt;
  #can have different deadlines.&lt;br /&gt;
  def add_signup_topics_staggered&lt;br /&gt;
    load_add_signup_topics(params[:id])&lt;br /&gt;
&lt;br /&gt;
    @review_rounds = Assignment.find(params[:id]).get_review_rounds&lt;br /&gt;
    @topics = SignUpTopic.find_all_by_assignment_id(params[:id])&lt;br /&gt;
&lt;br /&gt;
    #Use this until you figure out how to initialize this array&lt;br /&gt;
    @duedates = SignUpTopic.find_by_sql(&amp;quot;SELECT s.id as topic_id FROM sign_up_topics s WHERE s.assignment_id = &amp;quot; + params[:id].to_s)&lt;br /&gt;
&lt;br /&gt;
    if !@topics.nil?&lt;br /&gt;
      i=0&lt;br /&gt;
      @topics.each { |topic|&lt;br /&gt;
&lt;br /&gt;
        @duedates[i]['t_id'] = topic.id&lt;br /&gt;
        @duedates[i]['topic_identifier'] = topic.topic_identifier&lt;br /&gt;
        @duedates[i]['topic_name'] = topic.topic_name&lt;br /&gt;
&lt;br /&gt;
        for j in 1..@review_rounds&lt;br /&gt;
          if j == 1&lt;br /&gt;
            duedate_subm = TopicDeadline.find_by_topic_id_and_deadline_type_id(topic.id, DeadlineType.find_by_name('submission').id)&lt;br /&gt;
            duedate_rev = TopicDeadline.find_by_topic_id_and_deadline_type_id(topic.id, DeadlineType.find_by_name('review').id)&lt;br /&gt;
          else&lt;br /&gt;
            duedate_subm = TopicDeadline.find_by_topic_id_and_deadline_type_id_and_round(topic.id,              DeadlineType.find_by_name('resubmission').id, j)&lt;br /&gt;
            duedate_rev = TopicDeadline.find_by_topic_id_and_deadline_type_id_and_round(topic.id, DeadlineType.find_by_name('rereview').id, j)&lt;br /&gt;
          end&lt;br /&gt;
          if !duedate_subm.nil? &amp;amp;&amp;amp; !duedate_rev.nil?&lt;br /&gt;
            @duedates[i]['submission_'+ j.to_s] = DateTime.parse(duedate_subm['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
            @duedates[i]['review_'+ j.to_s] = DateTime.parse(duedate_rev['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
          else&lt;br /&gt;
            #the topic is new. so copy deadlines from assignment&lt;br /&gt;
            set_of_due_dates = DueDate.find_all_by_assignment_id(params[:id])&lt;br /&gt;
            set_of_due_dates.each { |due_date|&lt;br /&gt;
              create_topic_deadline(due_date, 0, topic.id)&lt;br /&gt;
            }&lt;br /&gt;
            # code execution would have hit the else part during review_round one. So we'll do only round one&lt;br /&gt;
            duedate_subm = TopicDeadline.find_by_topic_id_and_deadline_type_id(topic.id, DeadlineType.find_by_name('submission').id)&lt;br /&gt;
            duedate_rev = TopicDeadline.find_by_topic_id_and_deadline_type_id(topic.id, DeadlineType.find_by_name('review').id)&lt;br /&gt;
            @duedates[i]['submission_'+ j.to_s] = DateTime.parse(duedate_subm['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
            @duedates[i]['review_'+ j.to_s] = DateTime.parse(duedate_rev['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
        end&lt;br /&gt;
        duedate_subm = TopicDeadline.find_by_topic_id_and_deadline_type_id(topic.id, DeadlineType.find_by_name('metareview').id)&lt;br /&gt;
        if !duedate_subm.nil?&lt;br /&gt;
                                                                                                                                                                                                                                          @duedates[i]['submission_'+ (@review_rounds+1).to_s] = DateTime.parse(duedate_subm['due_at'].to_s).strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;)&lt;br /&gt;
        else&lt;br /&gt;
          @duedates[i]['submission_'+ (@review_rounds+1).to_s] = nil&lt;br /&gt;
        end&lt;br /&gt;
        i = i + 1&lt;br /&gt;
      }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81670</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81670"/>
		<updated>2013-10-31T00:16:40Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Introduction to Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It supports peer review, team assignments and submission of projects using any method like URL, wiki page or even code. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
According to the existing code flow, Assignment deadlines belonged to two categories i.e. Staggered Deadlines and Deadlines (Normal Due Date). If an Assignment has different topics which have dependencies i.e. if Assignment A has two topics Topic A and Topic B , where Topic A can have deadline before Topic B, and therefore the Due Date of Assignment A is dependent on deadlines of Topics designed in that particular assignment. Hence these deadlines are called Staggered Deadlines.&lt;br /&gt;
&lt;br /&gt;
Pre-refactored code had various check statements for staggered and normal deadlines, which had to eliminated and structured in a way that with minimum checks we could distinguish between Staggered and Normal Due Dates. This required refactoring and restructuring of the whole functionality where we reduce these checks by distributing code into separate actions.&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81664</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81664"/>
		<updated>2013-10-31T00:11:34Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Introduction to Expertiza */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a project developed using Ruby on Rails platform. It supports peer review, team assignments and submission of projects using any method like URL, wiki page or even code. It is open source application and the code can be cloned from [https://github.com/expertiza/expertiza github].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
===Current Scenario===&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work=&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81638</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81638"/>
		<updated>2013-10-30T23:55:38Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* Additional Learning and Future Work = */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project built using the Ruby on Rails platform. It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
= Re-factored Code Cases =&lt;br /&gt;
&lt;br /&gt;
== Case 1 : Refactoring in sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== Case 2 : Method Extraction  ==&lt;br /&gt;
&lt;br /&gt;
== Case 3 : Modularize Code in application.rb  ==&lt;br /&gt;
&lt;br /&gt;
== Case 4 : DeadCode Elimination in  sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work =&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81515</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 aas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_aas&amp;diff=81515"/>
		<updated>2013-10-30T23:06:27Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: Created page with &amp;quot;=E810 Regularize staggered-deadline assignments= This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Lang...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project built using the Ruby on Rails platform. It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;br /&gt;
&lt;br /&gt;
= Testing Steps =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modifications to Existing Code =&lt;br /&gt;
&lt;br /&gt;
== Changed File : sign_up_sheet_controller.rb ==&lt;br /&gt;
&lt;br /&gt;
== Changed File :.... ==&lt;br /&gt;
&lt;br /&gt;
== Changed File : ... ==&lt;br /&gt;
&lt;br /&gt;
== Changed File : ... ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Additional Learning and Future Work ==&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=81512</id>
		<title>CSC/ECE 517 Fall 2013</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=81512"/>
		<updated>2013-10-30T23:04:33Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[ CSC/ECE 517 Fall 2012/ch1 1w23 ph ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 nn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w21 w]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w01 aj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w24 nv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w29 rkld]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w25 aras]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 ps]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w19 rj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w18 bs]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w17 pk]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w22 ss]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w12 vn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w14 st]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w08 cc]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w10 ga ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w26 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w27 ma ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w13 aa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w11 sv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w07 d ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w20 gq ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w03 ss ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w28 nm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w02 pp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w6 zs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w04 y ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w05 st ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w09 hs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w32 av ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w48 x ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 av]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w46 ka]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w33 aa]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w35 sa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w39 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w31 vm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 sm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w44 s ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w47 ka ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w34 fs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w40 ao ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss fmv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss vna ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss paa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss mapFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch2 0e808 nsv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss aoa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss cmh ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ans ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E818 mra ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss SocialMediaFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E811 syn ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E804 spb ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E812 amp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss S805 ahs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E820 gzs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E816 cyy ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss M801 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E814 vd ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E815 saa]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E810 aas ]]&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_tr&amp;diff=81357</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 tr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_tr&amp;diff=81357"/>
		<updated>2013-10-30T21:17:38Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* E818 Refactoring and testing -- analytics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E810 Regularize staggered-deadline assignments=&lt;br /&gt;
This page provides a description of the OSS project conducted on Expertiza which was done as the part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project built using the Ruby on Rails platform. It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_tr&amp;diff=81235</id>
		<title>CSC/ECE 517 Fall 2013/oss E810 tr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_E810_tr&amp;diff=81235"/>
		<updated>2013-10-30T19:59:45Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: Wiki page for OSS assignment 2a&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E818 Refactoring and testing -- analytics=&lt;br /&gt;
This Wiki page provides a detailed description of the Open Source Software project conducted on Expertiza, as part of the Object Oriented Languages and Systems coursework.&lt;br /&gt;
&lt;br /&gt;
=Introduction to Expertiza=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project built using the Ruby on Rails platform. It is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities to manage peer reviews in coursework. The source code can be forked from [https://github.com/expertiza/expertiza github] and cloned for performing modifications. The Expertiza environment is already set up in NC State's VCL image &amp;quot;Ruby on Rails&amp;quot;. If you have access, this is quickest way to get a development environment running for Expertiza. See the Expertiza wiki(provide hyperlink) on developing Expertiza on the VCL.&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=81232</id>
		<title>CSC/ECE 517 Fall 2013</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013&amp;diff=81232"/>
		<updated>2013-10-30T19:57:51Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: Wiki Link for team Rails E810 staggered deadline&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[ CSC/ECE 517 Fall 2012/ch1 1w23 ph ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 nn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w21 w]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w01 aj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w24 nv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w29 rkld]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w25 aras]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w30 ps]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w19 rj]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w18 bs]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w17 pk]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w22 ss]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w12 vn]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w14 st]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w08 cc]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w10 ga ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w26 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w27 ma ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w13 aa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w11 sv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w07 d ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w20 gq ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w03 ss ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w28 nm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w02 pp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w6 zs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1  1w04 y ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w05 st ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w09 hs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w32 av ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w48 x ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 av]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w46 ka]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w33 aa]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w35 sa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w39 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w31 vm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w43 sm ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w44 s ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w47 ka ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w34 fs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch1 1w40 ao ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss fmv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss vna ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss paa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss mapFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/ch2 0e808 nsv ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss aoa ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss cmh ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ans ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss ssv]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E818 mra ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss SocialMediaFeeds ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E811 syn ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E804 spb ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E812 amp ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss S805 ahs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E820 gzs ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E816 cyy ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss M801 as ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E814 vd ]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E815 saa]]&lt;br /&gt;
* [[ CSC/ECE 517 Fall 2013/oss E810 tr ]]&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w01_aj&amp;diff=79238</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w01 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w01_aj&amp;diff=79238"/>
		<updated>2013-10-02T03:09:57Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* IBM Rational ClearCase */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Version Control Tools ==&lt;br /&gt;
&lt;br /&gt;
Version control tools are the tools which manage the changes to documents, computer programs, large web sites, and other collections of information. It is a repository of code along with the history of the changes. All the change made to the source is tracked, along with the other details like who made the changes, why the changes were made and other comments. This concept is very important for large projects requiring collaborated development. Whether it is the history of this wiki page or large software development project like Facebook, the ability to track the changes, and to reverse changes when necessary can make all huge difference between a well-managed and controlled process and an uncontrolled ‘first come, first served’ system. It can be used to track the development lifecycle of a project in detail.&lt;br /&gt;
&lt;br /&gt;
== Categories of version control tools ==&lt;br /&gt;
&lt;br /&gt;
=== Distributed Model ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Peer-to-peer Peer-to-peer] approach is followed in distributed revision control system in which each person’s copy of codebase is the current version of his code. In this way, each developer has the copy of full code rather than a part of code on which that developer is working. This system then synchronizes the copies of each developer by exchanging patches which contain the sets of changes. In this way each developer gets the latest copy of the code portion that others are working on. This method, most of the times, does not use the central repository. &lt;br /&gt;
Major advantages of this system are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	As the full code is available on the hard disk, most of the actions are very fast as the interaction with the remote server is not required.&lt;br /&gt;
&lt;br /&gt;
•	Committing new change sets can be done locally without anyone else seeing them. Once you have a group of change sets ready, you can push all of them at once.&lt;br /&gt;
&lt;br /&gt;
•	Except pushing and pulling, most of the actions can be performed without an internet connection.&lt;br /&gt;
&lt;br /&gt;
Despite the above advantages, Distributed Version Control Tools pose some problems. As the copy of whole code is maintained at the local machine, it requires a huge amount of space in case the files cannot be compressed (binary files). Moreover, in case the project has a huge history of changes, it might require large amount of time to download the entire patches.&lt;br /&gt;
&lt;br /&gt;
Few examples of such tools are Codeville, Fossil, LibreSource, Monotone,  Veracity and Git. &lt;br /&gt;
Let us consider Git to explain the features of distributed model for version control tools.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Git ====&lt;br /&gt;
Git is a free and open source distributed version control system. Its highest priority is to provide the high speed to its users. It was initially designed and developed for Linux kernel in 2005. was originally designed as a low-level version control system engine on top of which others could write front ends. However, the core Git project has since become a complete version control system that is usable directly. As of today, Git is estimated to have captured 30% of the market.&lt;br /&gt;
Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.&lt;br /&gt;
&lt;br /&gt;
[[File:Branching-Git.png]]&lt;br /&gt;
''(Image showing the concept of branching for Git)''&lt;br /&gt;
&lt;br /&gt;
==== Design of Git ====&lt;br /&gt;
Git, like any other distributed version control system, has three main functionalities:&lt;br /&gt;
&lt;br /&gt;
•	Code storage&lt;br /&gt;
&lt;br /&gt;
•	Keeping track of the changes made to the code&lt;br /&gt;
&lt;br /&gt;
•	Synchronizing all the developers for the latest code&lt;br /&gt;
&lt;br /&gt;
===== Code Storage =====&lt;br /&gt;
&lt;br /&gt;
Blob is the basic storage in Git. Git stores the contents of the file for tracking history, and not just the differences between individual files for each change. The contents are then referenced by a 40 character [http://en.wikipedia.org/wiki/SHA-1 SHA1 hash]. Pretty much every object, be it a commit, tree, or blob has a SHA.&lt;br /&gt;
&lt;br /&gt;
This gives an added advantage that if two or more copies of the same file are stored in the repository, Git will store only one file internally.&lt;br /&gt;
&lt;br /&gt;
The next level object is a tree. These can be thought of as folders or directories. Finally, this brings us to the most important object: the commit. Commits can be thought of as snapshots. The major difference between Git and any other tool is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes. Tools consider the information they keep as a set of files and the changes made to each file over time.&lt;br /&gt;
&lt;br /&gt;
[[File:Data_storage_git.png]]&lt;br /&gt;
''(Image showing data storage in case of normal control system)''&lt;br /&gt;
In contrast, Git thinks of its data more like a set of snapshots of a mini file system.&lt;br /&gt;
Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.&lt;br /&gt;
&lt;br /&gt;
Git stores data as:&lt;br /&gt;
 &lt;br /&gt;
[[File:Git_commit.png‎]]&lt;br /&gt;
''(Image showing data storage in case of Git)''&lt;br /&gt;
&lt;br /&gt;
This is an important difference between Git and all other tools. It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.&lt;br /&gt;
&lt;br /&gt;
===== Tracking the changes made to the code =====&lt;br /&gt;
Git uses directed acyclic graph to store its history. Each commit in Git can have multiple or single parent commits. This info about the ancestors is stored with each commit. Here we can have nonlinear history. That means a commit can have multiple parent commits on which the child commit depends. Below example shows 3-way merge that has 3 parents:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Git_Tree.png‎]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The history of a file is linked all the way up its directory structure to the root directory, which is then linked to a commit node. This commit node, in turn, can have one or more parents. When merging multiple branches we are merging the contents in a DAG. This allows Git to determine common ancestors.&lt;br /&gt;
&lt;br /&gt;
===== Synchronizing all the developers for the latest code =====&lt;br /&gt;
&lt;br /&gt;
In Git, when a developer makes the same modification to the equivalent file in the local Git code, the change will be recorded locally first, then they can &amp;quot;push&amp;quot; the commits to the other users who are working on the same project. The content changes are stored identically for each Git repository that the commit exists in. &lt;br /&gt;
Upon the local commit, the local Git repository will create a new object representing a file for the changed file. For each directory above the changed file, a new tree object is created with a new identifier. A DAG is created starting from the newly created root tree object pointing to the files and referencing the newly created blob in place of that file's previous blob object in the previous tree hierarchy.&lt;br /&gt;
At this point the commit is still local to the current Git code on developer’s local device. When he &amp;quot;pushes&amp;quot; the commit to a publicly accessible Git repository this commit gets sent to that repository. After the public repository verifies that the commit can apply to the branch, the same objects are stored in the public repository as were originally created in the local Git repository.&lt;br /&gt;
&lt;br /&gt;
==== Tools available for Git ====&lt;br /&gt;
&lt;br /&gt;
Git provides many command line and UI tools for most of the platforms. All these tools are based on Git core toolkit.&lt;br /&gt;
Git toolkit is divided into 2 parts: plumbing and porcelain. Plumbing contains two level commands that enable basic content tracking and modification of directed acyclic graphs. Procelain contains the more commonly used commands which are used to maintain repositories and communicating with other developers. Work is in progress for improving the toolkit design and making it faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Some of the major characteristics of Git: =====&lt;br /&gt;
===== Good support for expansion =====&lt;br /&gt;
Git is extremely fast and scalable. Referring to a local copy of code instead of the copy on remote server is very fast. As the project size increases, the affect of size on performance is very less.&lt;br /&gt;
&lt;br /&gt;
===== Distributed development =====&lt;br /&gt;
Each developer is provided with the local copy of the entire development history. Changes are copied from one of the repository to another. These changes are transferred and can integrate the same way the local branches of the repository.&lt;br /&gt;
&lt;br /&gt;
===== Backward compatibility =====&lt;br /&gt;
Repositories can be published by HTTP, FTP, rsync, or a Git protocol over either a plain socket, ssh or HTTP. Git also has a CVS server emulation, which enables the use of existing CVS clients and IDE plugins to access Git repositories.&lt;br /&gt;
&lt;br /&gt;
===== Non-linear development =====&lt;br /&gt;
Git provides quick branching and merging. A branch in git is only a reference to a single commit. It supports non-linear development through various tools.&lt;br /&gt;
&lt;br /&gt;
===== Support for incomplete merge =====&lt;br /&gt;
In case of an incomplete merge, Git provides multiple algorithms for letting the user know of this situation and also provides support for manual editing.&lt;br /&gt;
&lt;br /&gt;
===== Cryptographic authentication of history =====&lt;br /&gt;
Git stores the history so that the id of a particular version depends upon the history of changes resulting into that commit. Once it is published, it is not possible to change the old versions without it being noticed.&lt;br /&gt;
&lt;br /&gt;
Some of the major companies using Git in their projects include Google, Facebook, Microsoft(ASP.NET), Twitter, Eclipse and Netflix.&lt;br /&gt;
&lt;br /&gt;
'''Some of the other major tools in this category are given below'''&lt;br /&gt;
&lt;br /&gt;
==== GNU Bazaar ====&lt;br /&gt;
[http://en.wikipedia.org/wiki/GNU_Bazaar GNU Bazaar] (formerly Bazaar-NG, command line tool bzr) is a distributed revision control system sponsored by Canonical.&lt;br /&gt;
Bazaar can be used by a single developer working on multiple branches of local content, or by teams collaborating across a network.&lt;br /&gt;
Bazaar is written in the Python programming language, with packages for major GNU/Linux distributions, Mac OS X and Microsoft Windows.&lt;br /&gt;
&lt;br /&gt;
==== Mercurial ====&lt;br /&gt;
[http://mercurial.selenic.com/ Mercurial] is a cross-platform, distributed revision control tool for software developers. It is mainly implemented using the Python programming language, but includes a binary diff implementation written in C. It is supported on Windows and Unix-like systems, such as FreeBSD, Mac OS X andLinux. Mercurial is primarily a command line program but graphical user interface extensions are available. All of Mercurial's operations are invoked as arguments to its driver program hg, a reference to the chemical symbol of the element mercury.&lt;br /&gt;
&lt;br /&gt;
==== Bitkeeper ====&lt;br /&gt;
[http://www.bitkeeper.com/ BitKeeper] is a software tool for distributed revision control (configuration management, SCM, etc.) of computer source code. A distributed system, BitKeeper competes largely against other systems such as Git and Mercurial. BitKeeper is produced by BitMover Inc., a privately held company based in Campbell, California[2] and owned by CEO Larry McVoy, who had previously designed TeamWare.&lt;br /&gt;
&lt;br /&gt;
BitKeeper builds upon many of the TeamWare concepts. Its key selling point is the fact that it is a distributed version control tool, as opposed to CVSor SVN. One of the defining characteristics of any distributed version control tool is the ease with which distributed development teams can keep their own local source repositories and still work with the central repository. Its web site claims that &amp;quot;BitKeeper has been shown to double the pace of software development&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Client Server Model ===&lt;br /&gt;
Centralized or client-server version control systems are based on the idea that there is a single “central” copy of your project somewhere (probably on a server), and programmers will “commit” their changes to this central copy.&lt;br /&gt;
&lt;br /&gt;
“Committing” a change simply means recording the change in the central system. Other programmers can then see this change. They can also pull down the change, and the version control tool will automatically update the contents of any files that were changed.&lt;br /&gt;
&lt;br /&gt;
Most modern version control systems deal with “changesets,” which simply are a groups of changes (possibly to many files) that should be treated as a cohesive whole. For example: a change to a C header file and the corresponding .c file should always be kept together.&lt;br /&gt;
&lt;br /&gt;
==== Major Advantages of Centralized Version Control over Distributed Version Control ====&lt;br /&gt;
If the project contains many large, binary files that cannot be easily compressed, the space needed to store all versions of these files can accumulate quickly.&lt;br /&gt;
&lt;br /&gt;
If the project has a very long history (50,000 changesets or more), downloading the entire history can take an impractical amount of time and disk space.&lt;br /&gt;
&lt;br /&gt;
==== Perforce ====&lt;br /&gt;
Perforce is an enterprise version control and management system which uses centralized Version Control System. Dedicated Perforce applications are used to sync files between the file repository and individual users' workstations. &lt;br /&gt;
Perforce supports both Git clients and clients that use Perforce's own protocol. A Git client can communicate with the Perforce server over SSH, and other Perforce clients communicate with the server via TCP/IP using a proprietary RPC and streaming protocol.&lt;br /&gt;
&lt;br /&gt;
[[File:perf1.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== The Perforce Versioning Service =====&lt;br /&gt;
The Perforce versioning service manages shared file repositories called depots. Depots contains all revisions of all file under Perforce control. Perforce organizes all the files in depots into directory trees, like a hard drive. Files in a depot are referred to as depot files or versioned files. Files are identified by namespace (i.e., by OS-neutral filenames). File content itself is not stored in the database. MD5 hashes of file content are stored in the database. Text file revisions are stored as RCS deltas and binary file revisions are stored in their entirety. &lt;br /&gt;
&lt;br /&gt;
　　The service maintains a database to track change logs, user permissions, and which users have which files checked out at any time. The &lt;br /&gt;
information stored in this database is referred to as metadata. &lt;br /&gt;
&lt;br /&gt;
　　Database tables are stored as binary files. Checkpoints and journals are written as text files that can be compressed and taken out. A database that has been corrupted by hardware failure or other catastrophe can be recovered from the most recent journal and checkpoint. Administrators must plan for disaster recovery by configuring database journaling and setting up regular checkpoints.&lt;br /&gt;
&lt;br /&gt;
[[File:perf2.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== Perforce applications (clients) =====&lt;br /&gt;
Dedicated Perforce applications communicate with the versioning service to enable the checking in and out, conflict management, branch development, bug tracking request changing and more. They include:&lt;br /&gt;
&lt;br /&gt;
　　• P4, the Perforce Command-Line Client, for all platforms&lt;br /&gt;
&lt;br /&gt;
　　• P4V, the Perforce Visual Client, for Mac OS X, UNIX, Linux, and Windows&lt;br /&gt;
&lt;br /&gt;
　　• P4Web, the Perforce Web Client, a browser-based interface to Perforce&lt;br /&gt;
&lt;br /&gt;
　　• Integrations, or plug-ins, that work with commercial IDEs and productivity software&lt;br /&gt;
&lt;br /&gt;
　　&lt;br /&gt;
When the files are loaded into the workspace, the Perforce application requests the files from the central data repository. To optimize the network utilization, the service keeps track of which files you (and other users) have retrieved. Perforce applications do not require a persistent connection to the versioning service.&lt;br /&gt;
&lt;br /&gt;
===== Connecting and Mapping files to the workspace =====&lt;br /&gt;
　　Perforce applications manages files in a certain location of the hard disk, called the workspace. More than one client workspace can co-exist, even on the same workstation.&lt;br /&gt;
&lt;br /&gt;
　　To customize the location of depot files under the root workspace, users must map the files and directories on the shared versioning service to corresponding areas of local hard drive.&lt;br /&gt;
　　Workspace views:&lt;br /&gt;
&lt;br /&gt;
　　• Determine which files in the depot needs to be in the workspace.&lt;br /&gt;
&lt;br /&gt;
　　• Custom-map files in the depot to files in the workspace.&lt;br /&gt;
&lt;br /&gt;
　　Client workspace views may consist multiple lines or mappings. Each line in the workspace view has a &amp;quot;depot side&amp;quot;, designates a subset of files within the depot, and a &amp;quot;client side&amp;quot; that controls where the files specified on the depot side are located under the workspace root.&lt;br /&gt;
&lt;br /&gt;
[[File:perf3.jpg]]&lt;br /&gt;
&lt;br /&gt;
=====　What file types are supported? =====&lt;br /&gt;
　　Perforce file types include seven base file types.&lt;br /&gt;
&lt;br /&gt;
　　• text files,&lt;br /&gt;
&lt;br /&gt;
　　• binary files,&lt;br /&gt;
&lt;br /&gt;
　　• native apple files on the Macintosh,&lt;br /&gt;
&lt;br /&gt;
　　• Mac resource forks,&lt;br /&gt;
&lt;br /&gt;
　　• symbolic links (symlinks),&lt;br /&gt;
&lt;br /&gt;
　　• unicode (and utf16) files.&lt;br /&gt;
&lt;br /&gt;
===== Working with files =====&lt;br /&gt;
The changelist is the fundamental unit of work. The basic file operations which are common to all VCS (such as editing, adding, deleting, rolling back changes, and file check in) are taken care in changelists.&lt;br /&gt;
A changelist consists file list, their revision numbers, the changes made, and a description that describes the work that has been performed.&lt;br /&gt;
Changelists serve two purposes:&lt;br /&gt;
&lt;br /&gt;
　　• To logically organize the work by grouping related changes to files together,&lt;br /&gt;
&lt;br /&gt;
　　• To ensure the work integrity by making sure that related changes to files are checked in together.&lt;br /&gt;
&lt;br /&gt;
Perforce changelists are atomic change transactions; if a changelist affects three files, then the changes for all three files are committed to the depot, or none of the changes are. Even if the network connection between your Perforce client program and the Perforce server is interrupted during changelist submission, the entire submit fails. Each changelist is identified by a changelist number (generated by Perforce), and a description (supplied by the user).&lt;br /&gt;
&lt;br /&gt;
[[File:perf4.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== Working concurrently =====&lt;br /&gt;
　　Perforce helps teams to work concurrently. The conflict resolution and three-way merge process enables multiple users to work on the same files at the same time without interfering with each other's work.&lt;br /&gt;
&lt;br /&gt;
　　The three-way merge process for resolving file conflicts helps you to resolve conflicting changes to text files, but is not necessarily meaningful for binary files such as graphics or compiled code. If the user is working on files where merges are not meaningful, locking such files is an option to prevent others from making changes that conflict.&lt;br /&gt;
&lt;br /&gt;
　　Perforce supports two types of file locking:&lt;br /&gt;
&lt;br /&gt;
　　• To prevent inconsistencies in current file changes, lock the file. Other users can still check out the locked file, but are restricted to view only privileges.&lt;br /&gt;
&lt;br /&gt;
　　• To prevent a file from being checked out by more than one user at a time, use the +l exclusive-open filetype modifier. Files that have the +l filetype modifier can only be opened by one user at a time. Your Perforce administrator can use a special table called the typemap table to automatically specify certain file types as exclusive-open.&lt;br /&gt;
　　&lt;br /&gt;
=====　Streams =====&lt;br /&gt;
　　Perforce streams are structured containers for the files that consist projects, codelines, and components. Streams confer the following benefits:&lt;br /&gt;
&lt;br /&gt;
　　• Ensures a hierarchical approach to branching&lt;br /&gt;
&lt;br /&gt;
　　• Provides an &amp;quot;out of the box&amp;quot; best-practice branching strategy&lt;br /&gt;
&lt;br /&gt;
　　• Provide metadata about the branch hierarchy to the Perforce service&lt;br /&gt;
&lt;br /&gt;
　　• Provide a standard approach to structuring code (stability and hierarchy)&lt;br /&gt;
&lt;br /&gt;
　　• Automate the generation of client workspace views and branch views&lt;br /&gt;
&lt;br /&gt;
　　• Offer a compelling and informative visualization of stream structure and status&lt;br /&gt;
&lt;br /&gt;
　　• Enable you to organize and visualize (bodies of) code.&lt;br /&gt;
&lt;br /&gt;
　　• Provide rules to make development easier.&lt;br /&gt;
　　&lt;br /&gt;
=====　Codeline Management =====&lt;br /&gt;
Codelines are inter-related files that grow together. To organize groups of related files by purpose, branches are created. To move changes between branches, changelists are integrated. To create a snapshot of files in a specific phase, labels can be used.&lt;br /&gt;
　　&lt;br /&gt;
=====　Branching =====&lt;br /&gt;
　　Branching is a method of managing changes between two or more sets of files. Perforce's Inter-File Branching mechanism enables copying of any set of files to a new location in the depot by allowing changes made to one set of files to be copied, or integrated, to the other. The new file set (or codeline) evolves separately from the original files, but changes in either codeline can be propagated to the other by means of integration. Almost all of the version control systems support some form of branching.&lt;br /&gt;
&lt;br /&gt;
　　Merging is actually only one of three possible outcomes of an integration. The others are ignoring (aka &amp;quot;blocking&amp;quot;) and copying (aka &amp;quot;promoting&amp;quot;). Merging is used to keep one set of files up to date with another. For example, a development branch may be kept up to date with its trunk through repeated merging. Ignoring disqualifies changes in one set of files from future integration into another. It is often used when a development branch must be up to date with, and yet divergent from, its trunk. Copying is typically used to promote the content of an up-to-date development branch into a trunk.&lt;br /&gt;
&lt;br /&gt;
'''Some other tools in this category are given below'''&lt;br /&gt;
&lt;br /&gt;
==== AccuRev ====&lt;br /&gt;
[http://www.accurev.com/ AccuRev] is a centralized version control system which uses a client/server model. Communication is performed via TCP/IP using a proprietary protocol. Servers function as team servers, continuous integration servers, or build servers. AccuRev is built around a stream-based architecture in which streams form a hierarchical structure of code changes where parent streams pass on certain properties to child streams. Developers make changes using command line functions, the Java GUI, the web interface, or one of the IDE plug-ins.&lt;br /&gt;
&lt;br /&gt;
Characteristics:&lt;br /&gt;
&lt;br /&gt;
• Streams and parallel development&lt;br /&gt;
&lt;br /&gt;
• Private developer history&lt;br /&gt;
&lt;br /&gt;
• Change packages&lt;br /&gt;
&lt;br /&gt;
• Distributed development&lt;br /&gt;
&lt;br /&gt;
• Automated merging&lt;br /&gt;
&lt;br /&gt;
==== IBM Rational ClearCase ====&lt;br /&gt;
[http://www-03.ibm.com/software/products/us/en/clearcase/ The Rational ClearCase] family consists of several software tools for supporting software configuration management (SCM) of source code and other software development assets. It is developed by the Rational Software division of IBM. ClearCase forms the base for configuration management for many large and medium sized businesses and can handle projects with hundreds or thousands of developers.&lt;br /&gt;
A part of Rational ClearCase is revision control system, which is a feature for end users.&lt;br /&gt;
&lt;br /&gt;
ClearCase supports two kinds of use models, UCM (Unified Change Management), and base ClearCase. UCM provides an out-of-the-box model while base ClearCase provides a basic infrastructure (upon which UCM is built). Both can be configured to support a wide variety of needs. UCM is part of RUP (Rational Unified Process) and therefore all process templates and roles can be used from RUP.&lt;br /&gt;
&lt;br /&gt;
'''Features:'''&lt;br /&gt;
&lt;br /&gt;
• Build auditing&lt;br /&gt;
&lt;br /&gt;
• VOB (Versioned Object Base)&lt;br /&gt;
&lt;br /&gt;
• Configuration Record&lt;br /&gt;
&lt;br /&gt;
• Build Avoidance&lt;br /&gt;
&lt;br /&gt;
• Unix/Windows Interoperability&lt;br /&gt;
&lt;br /&gt;
• Integration With Other Products&lt;br /&gt;
&lt;br /&gt;
• Space Saving&lt;br /&gt;
&lt;br /&gt;
'''Weaknesses:'''&lt;br /&gt;
&lt;br /&gt;
• Speed&lt;br /&gt;
&lt;br /&gt;
• Sensitivity to network problems&lt;br /&gt;
&lt;br /&gt;
=== Local Data Model ===&lt;br /&gt;
In the local-only approach, all developers must use the same computer system. These software often manage single files individually and are largely replaced or embedded within newer software. This data model is the grandfather of all the modern version control softwares. These are the very first softwares for version control that were implemented in the late 1970's. Technological and software advances have rendered these practically useless but certain legacy systems still use these due to the hardware and software limitations.&lt;br /&gt;
&lt;br /&gt;
==== Source Code Control System (SCCS) ====&lt;br /&gt;
　　Source Code Control System (SCCS) is an early revision control system, geared toward program source code and other text files. It was originally developed in SNOBOL at Bell Labs in 1972 by Marc Rochkind for an IBM System/370 computer running OS/360 MVT. SCCS was the dominant version control system for Unix until the release of the Revision Control System (RCS)[dubious – discuss]. Today, SCCS is generally considered obsolete. However, its file format is still used internally by a few other revision control programs, including BitKeeper and TeamWare. The latter is a frontend to SCCS. Sablime has been developed from a modified version of SCCS but uses a history file format that is incompatible with SCCS. The SCCS file format uses a storage technique called interleaved deltas (or the weave). This storage technique is now considered by many revision control system developers as foundational to advanced merging and versioning techniques, such as the &amp;quot;Precise Codeville&amp;quot; (&amp;quot;pcdv&amp;quot;) merge.&lt;br /&gt;
　　&lt;br /&gt;
==== Revision Control System (RCS) ====&lt;br /&gt;
The Revision Control System (RCS) is a software implementation of revision control that automates the storing, retrieval, logging, identification, and merging of revisions. RCS is useful for text that is revised frequently, for example programs, documentation, procedural graphics, papers, and form letters. RCS is also capable of handling binary files, though with reduced efficiency. Revisions are stored with the aid of the diff utility.&lt;br /&gt;
&lt;br /&gt;
This came into existency in 1982 and gave the version control systems a new dimension. It was the best VCS for the single user system, where all the files related to a project are in a single system. RCS just locks a single file that is being used and doesn't lock the entire project which is computationally cheaper.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. [http://www.oss-watch.ac.uk/resources/versioncontrol Version Control Tools]&lt;br /&gt;
&lt;br /&gt;
2. [http://www.mediamosa.org/content/source-code DVS]&lt;br /&gt;
&lt;br /&gt;
3. [http://blogs.atlassian.com/2012/02/version-control-centralized-dvcs/ Distributed Version Control]&lt;br /&gt;
&lt;br /&gt;
4. [http://git-scm.com/ Git]&lt;br /&gt;
&lt;br /&gt;
5. [http://gitready.com/beginner/2009/02/17/how-git-stores-your-data.html GitReady]&lt;br /&gt;
&lt;br /&gt;
6. [https://wiki.archlinux.org/index.php/Git‎ Archlinux] &lt;br /&gt;
&lt;br /&gt;
7. [http://stackoverflow.com/questions/8198105/how-git-stores-files StackOverflow]&lt;br /&gt;
&lt;br /&gt;
8. [http://en.wikipedia.org Wikipedia]&lt;br /&gt;
&lt;br /&gt;
9. [http://www.perforce.com/perforce/doc.current/manuals/p4v-gs/p4v-gs.pdf Perforce documentation and manuals ‎]&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w01_aj&amp;diff=79237</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w01 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w01_aj&amp;diff=79237"/>
		<updated>2013-10-02T03:09:25Z</updated>

		<summary type="html">&lt;p&gt;Abhutan: /* AccuRev */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Version Control Tools ==&lt;br /&gt;
&lt;br /&gt;
Version control tools are the tools which manage the changes to documents, computer programs, large web sites, and other collections of information. It is a repository of code along with the history of the changes. All the change made to the source is tracked, along with the other details like who made the changes, why the changes were made and other comments. This concept is very important for large projects requiring collaborated development. Whether it is the history of this wiki page or large software development project like Facebook, the ability to track the changes, and to reverse changes when necessary can make all huge difference between a well-managed and controlled process and an uncontrolled ‘first come, first served’ system. It can be used to track the development lifecycle of a project in detail.&lt;br /&gt;
&lt;br /&gt;
== Categories of version control tools ==&lt;br /&gt;
&lt;br /&gt;
=== Distributed Model ===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Peer-to-peer Peer-to-peer] approach is followed in distributed revision control system in which each person’s copy of codebase is the current version of his code. In this way, each developer has the copy of full code rather than a part of code on which that developer is working. This system then synchronizes the copies of each developer by exchanging patches which contain the sets of changes. In this way each developer gets the latest copy of the code portion that others are working on. This method, most of the times, does not use the central repository. &lt;br /&gt;
Major advantages of this system are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
•	As the full code is available on the hard disk, most of the actions are very fast as the interaction with the remote server is not required.&lt;br /&gt;
&lt;br /&gt;
•	Committing new change sets can be done locally without anyone else seeing them. Once you have a group of change sets ready, you can push all of them at once.&lt;br /&gt;
&lt;br /&gt;
•	Except pushing and pulling, most of the actions can be performed without an internet connection.&lt;br /&gt;
&lt;br /&gt;
Despite the above advantages, Distributed Version Control Tools pose some problems. As the copy of whole code is maintained at the local machine, it requires a huge amount of space in case the files cannot be compressed (binary files). Moreover, in case the project has a huge history of changes, it might require large amount of time to download the entire patches.&lt;br /&gt;
&lt;br /&gt;
Few examples of such tools are Codeville, Fossil, LibreSource, Monotone,  Veracity and Git. &lt;br /&gt;
Let us consider Git to explain the features of distributed model for version control tools.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Git ====&lt;br /&gt;
Git is a free and open source distributed version control system. Its highest priority is to provide the high speed to its users. It was initially designed and developed for Linux kernel in 2005. was originally designed as a low-level version control system engine on top of which others could write front ends. However, the core Git project has since become a complete version control system that is usable directly. As of today, Git is estimated to have captured 30% of the market.&lt;br /&gt;
Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.&lt;br /&gt;
&lt;br /&gt;
[[File:Branching-Git.png]]&lt;br /&gt;
''(Image showing the concept of branching for Git)''&lt;br /&gt;
&lt;br /&gt;
==== Design of Git ====&lt;br /&gt;
Git, like any other distributed version control system, has three main functionalities:&lt;br /&gt;
&lt;br /&gt;
•	Code storage&lt;br /&gt;
&lt;br /&gt;
•	Keeping track of the changes made to the code&lt;br /&gt;
&lt;br /&gt;
•	Synchronizing all the developers for the latest code&lt;br /&gt;
&lt;br /&gt;
===== Code Storage =====&lt;br /&gt;
&lt;br /&gt;
Blob is the basic storage in Git. Git stores the contents of the file for tracking history, and not just the differences between individual files for each change. The contents are then referenced by a 40 character [http://en.wikipedia.org/wiki/SHA-1 SHA1 hash]. Pretty much every object, be it a commit, tree, or blob has a SHA.&lt;br /&gt;
&lt;br /&gt;
This gives an added advantage that if two or more copies of the same file are stored in the repository, Git will store only one file internally.&lt;br /&gt;
&lt;br /&gt;
The next level object is a tree. These can be thought of as folders or directories. Finally, this brings us to the most important object: the commit. Commits can be thought of as snapshots. The major difference between Git and any other tool is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes. Tools consider the information they keep as a set of files and the changes made to each file over time.&lt;br /&gt;
&lt;br /&gt;
[[File:Data_storage_git.png]]&lt;br /&gt;
''(Image showing data storage in case of normal control system)''&lt;br /&gt;
In contrast, Git thinks of its data more like a set of snapshots of a mini file system.&lt;br /&gt;
Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.&lt;br /&gt;
&lt;br /&gt;
Git stores data as:&lt;br /&gt;
 &lt;br /&gt;
[[File:Git_commit.png‎]]&lt;br /&gt;
''(Image showing data storage in case of Git)''&lt;br /&gt;
&lt;br /&gt;
This is an important difference between Git and all other tools. It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.&lt;br /&gt;
&lt;br /&gt;
===== Tracking the changes made to the code =====&lt;br /&gt;
Git uses directed acyclic graph to store its history. Each commit in Git can have multiple or single parent commits. This info about the ancestors is stored with each commit. Here we can have nonlinear history. That means a commit can have multiple parent commits on which the child commit depends. Below example shows 3-way merge that has 3 parents:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Git_Tree.png‎]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The history of a file is linked all the way up its directory structure to the root directory, which is then linked to a commit node. This commit node, in turn, can have one or more parents. When merging multiple branches we are merging the contents in a DAG. This allows Git to determine common ancestors.&lt;br /&gt;
&lt;br /&gt;
===== Synchronizing all the developers for the latest code =====&lt;br /&gt;
&lt;br /&gt;
In Git, when a developer makes the same modification to the equivalent file in the local Git code, the change will be recorded locally first, then they can &amp;quot;push&amp;quot; the commits to the other users who are working on the same project. The content changes are stored identically for each Git repository that the commit exists in. &lt;br /&gt;
Upon the local commit, the local Git repository will create a new object representing a file for the changed file. For each directory above the changed file, a new tree object is created with a new identifier. A DAG is created starting from the newly created root tree object pointing to the files and referencing the newly created blob in place of that file's previous blob object in the previous tree hierarchy.&lt;br /&gt;
At this point the commit is still local to the current Git code on developer’s local device. When he &amp;quot;pushes&amp;quot; the commit to a publicly accessible Git repository this commit gets sent to that repository. After the public repository verifies that the commit can apply to the branch, the same objects are stored in the public repository as were originally created in the local Git repository.&lt;br /&gt;
&lt;br /&gt;
==== Tools available for Git ====&lt;br /&gt;
&lt;br /&gt;
Git provides many command line and UI tools for most of the platforms. All these tools are based on Git core toolkit.&lt;br /&gt;
Git toolkit is divided into 2 parts: plumbing and porcelain. Plumbing contains two level commands that enable basic content tracking and modification of directed acyclic graphs. Procelain contains the more commonly used commands which are used to maintain repositories and communicating with other developers. Work is in progress for improving the toolkit design and making it faster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Some of the major characteristics of Git: =====&lt;br /&gt;
===== Good support for expansion =====&lt;br /&gt;
Git is extremely fast and scalable. Referring to a local copy of code instead of the copy on remote server is very fast. As the project size increases, the affect of size on performance is very less.&lt;br /&gt;
&lt;br /&gt;
===== Distributed development =====&lt;br /&gt;
Each developer is provided with the local copy of the entire development history. Changes are copied from one of the repository to another. These changes are transferred and can integrate the same way the local branches of the repository.&lt;br /&gt;
&lt;br /&gt;
===== Backward compatibility =====&lt;br /&gt;
Repositories can be published by HTTP, FTP, rsync, or a Git protocol over either a plain socket, ssh or HTTP. Git also has a CVS server emulation, which enables the use of existing CVS clients and IDE plugins to access Git repositories.&lt;br /&gt;
&lt;br /&gt;
===== Non-linear development =====&lt;br /&gt;
Git provides quick branching and merging. A branch in git is only a reference to a single commit. It supports non-linear development through various tools.&lt;br /&gt;
&lt;br /&gt;
===== Support for incomplete merge =====&lt;br /&gt;
In case of an incomplete merge, Git provides multiple algorithms for letting the user know of this situation and also provides support for manual editing.&lt;br /&gt;
&lt;br /&gt;
===== Cryptographic authentication of history =====&lt;br /&gt;
Git stores the history so that the id of a particular version depends upon the history of changes resulting into that commit. Once it is published, it is not possible to change the old versions without it being noticed.&lt;br /&gt;
&lt;br /&gt;
Some of the major companies using Git in their projects include Google, Facebook, Microsoft(ASP.NET), Twitter, Eclipse and Netflix.&lt;br /&gt;
&lt;br /&gt;
'''Some of the other major tools in this category are given below'''&lt;br /&gt;
&lt;br /&gt;
==== GNU Bazaar ====&lt;br /&gt;
[http://en.wikipedia.org/wiki/GNU_Bazaar GNU Bazaar] (formerly Bazaar-NG, command line tool bzr) is a distributed revision control system sponsored by Canonical.&lt;br /&gt;
Bazaar can be used by a single developer working on multiple branches of local content, or by teams collaborating across a network.&lt;br /&gt;
Bazaar is written in the Python programming language, with packages for major GNU/Linux distributions, Mac OS X and Microsoft Windows.&lt;br /&gt;
&lt;br /&gt;
==== Mercurial ====&lt;br /&gt;
[http://mercurial.selenic.com/ Mercurial] is a cross-platform, distributed revision control tool for software developers. It is mainly implemented using the Python programming language, but includes a binary diff implementation written in C. It is supported on Windows and Unix-like systems, such as FreeBSD, Mac OS X andLinux. Mercurial is primarily a command line program but graphical user interface extensions are available. All of Mercurial's operations are invoked as arguments to its driver program hg, a reference to the chemical symbol of the element mercury.&lt;br /&gt;
&lt;br /&gt;
==== Bitkeeper ====&lt;br /&gt;
[http://www.bitkeeper.com/ BitKeeper] is a software tool for distributed revision control (configuration management, SCM, etc.) of computer source code. A distributed system, BitKeeper competes largely against other systems such as Git and Mercurial. BitKeeper is produced by BitMover Inc., a privately held company based in Campbell, California[2] and owned by CEO Larry McVoy, who had previously designed TeamWare.&lt;br /&gt;
&lt;br /&gt;
BitKeeper builds upon many of the TeamWare concepts. Its key selling point is the fact that it is a distributed version control tool, as opposed to CVSor SVN. One of the defining characteristics of any distributed version control tool is the ease with which distributed development teams can keep their own local source repositories and still work with the central repository. Its web site claims that &amp;quot;BitKeeper has been shown to double the pace of software development&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Client Server Model ===&lt;br /&gt;
Centralized or client-server version control systems are based on the idea that there is a single “central” copy of your project somewhere (probably on a server), and programmers will “commit” their changes to this central copy.&lt;br /&gt;
&lt;br /&gt;
“Committing” a change simply means recording the change in the central system. Other programmers can then see this change. They can also pull down the change, and the version control tool will automatically update the contents of any files that were changed.&lt;br /&gt;
&lt;br /&gt;
Most modern version control systems deal with “changesets,” which simply are a groups of changes (possibly to many files) that should be treated as a cohesive whole. For example: a change to a C header file and the corresponding .c file should always be kept together.&lt;br /&gt;
&lt;br /&gt;
==== Major Advantages of Centralized Version Control over Distributed Version Control ====&lt;br /&gt;
If the project contains many large, binary files that cannot be easily compressed, the space needed to store all versions of these files can accumulate quickly.&lt;br /&gt;
&lt;br /&gt;
If the project has a very long history (50,000 changesets or more), downloading the entire history can take an impractical amount of time and disk space.&lt;br /&gt;
&lt;br /&gt;
==== Perforce ====&lt;br /&gt;
Perforce is an enterprise version control and management system which uses centralized Version Control System. Dedicated Perforce applications are used to sync files between the file repository and individual users' workstations. &lt;br /&gt;
Perforce supports both Git clients and clients that use Perforce's own protocol. A Git client can communicate with the Perforce server over SSH, and other Perforce clients communicate with the server via TCP/IP using a proprietary RPC and streaming protocol.&lt;br /&gt;
&lt;br /&gt;
[[File:perf1.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== The Perforce Versioning Service =====&lt;br /&gt;
The Perforce versioning service manages shared file repositories called depots. Depots contains all revisions of all file under Perforce control. Perforce organizes all the files in depots into directory trees, like a hard drive. Files in a depot are referred to as depot files or versioned files. Files are identified by namespace (i.e., by OS-neutral filenames). File content itself is not stored in the database. MD5 hashes of file content are stored in the database. Text file revisions are stored as RCS deltas and binary file revisions are stored in their entirety. &lt;br /&gt;
&lt;br /&gt;
　　The service maintains a database to track change logs, user permissions, and which users have which files checked out at any time. The &lt;br /&gt;
information stored in this database is referred to as metadata. &lt;br /&gt;
&lt;br /&gt;
　　Database tables are stored as binary files. Checkpoints and journals are written as text files that can be compressed and taken out. A database that has been corrupted by hardware failure or other catastrophe can be recovered from the most recent journal and checkpoint. Administrators must plan for disaster recovery by configuring database journaling and setting up regular checkpoints.&lt;br /&gt;
&lt;br /&gt;
[[File:perf2.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== Perforce applications (clients) =====&lt;br /&gt;
Dedicated Perforce applications communicate with the versioning service to enable the checking in and out, conflict management, branch development, bug tracking request changing and more. They include:&lt;br /&gt;
&lt;br /&gt;
　　• P4, the Perforce Command-Line Client, for all platforms&lt;br /&gt;
&lt;br /&gt;
　　• P4V, the Perforce Visual Client, for Mac OS X, UNIX, Linux, and Windows&lt;br /&gt;
&lt;br /&gt;
　　• P4Web, the Perforce Web Client, a browser-based interface to Perforce&lt;br /&gt;
&lt;br /&gt;
　　• Integrations, or plug-ins, that work with commercial IDEs and productivity software&lt;br /&gt;
&lt;br /&gt;
　　&lt;br /&gt;
When the files are loaded into the workspace, the Perforce application requests the files from the central data repository. To optimize the network utilization, the service keeps track of which files you (and other users) have retrieved. Perforce applications do not require a persistent connection to the versioning service.&lt;br /&gt;
&lt;br /&gt;
===== Connecting and Mapping files to the workspace =====&lt;br /&gt;
　　Perforce applications manages files in a certain location of the hard disk, called the workspace. More than one client workspace can co-exist, even on the same workstation.&lt;br /&gt;
&lt;br /&gt;
　　To customize the location of depot files under the root workspace, users must map the files and directories on the shared versioning service to corresponding areas of local hard drive.&lt;br /&gt;
　　Workspace views:&lt;br /&gt;
&lt;br /&gt;
　　• Determine which files in the depot needs to be in the workspace.&lt;br /&gt;
&lt;br /&gt;
　　• Custom-map files in the depot to files in the workspace.&lt;br /&gt;
&lt;br /&gt;
　　Client workspace views may consist multiple lines or mappings. Each line in the workspace view has a &amp;quot;depot side&amp;quot;, designates a subset of files within the depot, and a &amp;quot;client side&amp;quot; that controls where the files specified on the depot side are located under the workspace root.&lt;br /&gt;
&lt;br /&gt;
[[File:perf3.jpg]]&lt;br /&gt;
&lt;br /&gt;
=====　What file types are supported? =====&lt;br /&gt;
　　Perforce file types include seven base file types.&lt;br /&gt;
&lt;br /&gt;
　　• text files,&lt;br /&gt;
&lt;br /&gt;
　　• binary files,&lt;br /&gt;
&lt;br /&gt;
　　• native apple files on the Macintosh,&lt;br /&gt;
&lt;br /&gt;
　　• Mac resource forks,&lt;br /&gt;
&lt;br /&gt;
　　• symbolic links (symlinks),&lt;br /&gt;
&lt;br /&gt;
　　• unicode (and utf16) files.&lt;br /&gt;
&lt;br /&gt;
===== Working with files =====&lt;br /&gt;
The changelist is the fundamental unit of work. The basic file operations which are common to all VCS (such as editing, adding, deleting, rolling back changes, and file check in) are taken care in changelists.&lt;br /&gt;
A changelist consists file list, their revision numbers, the changes made, and a description that describes the work that has been performed.&lt;br /&gt;
Changelists serve two purposes:&lt;br /&gt;
&lt;br /&gt;
　　• To logically organize the work by grouping related changes to files together,&lt;br /&gt;
&lt;br /&gt;
　　• To ensure the work integrity by making sure that related changes to files are checked in together.&lt;br /&gt;
&lt;br /&gt;
Perforce changelists are atomic change transactions; if a changelist affects three files, then the changes for all three files are committed to the depot, or none of the changes are. Even if the network connection between your Perforce client program and the Perforce server is interrupted during changelist submission, the entire submit fails. Each changelist is identified by a changelist number (generated by Perforce), and a description (supplied by the user).&lt;br /&gt;
&lt;br /&gt;
[[File:perf4.jpg]]&lt;br /&gt;
&lt;br /&gt;
===== Working concurrently =====&lt;br /&gt;
　　Perforce helps teams to work concurrently. The conflict resolution and three-way merge process enables multiple users to work on the same files at the same time without interfering with each other's work.&lt;br /&gt;
&lt;br /&gt;
　　The three-way merge process for resolving file conflicts helps you to resolve conflicting changes to text files, but is not necessarily meaningful for binary files such as graphics or compiled code. If the user is working on files where merges are not meaningful, locking such files is an option to prevent others from making changes that conflict.&lt;br /&gt;
&lt;br /&gt;
　　Perforce supports two types of file locking:&lt;br /&gt;
&lt;br /&gt;
　　• To prevent inconsistencies in current file changes, lock the file. Other users can still check out the locked file, but are restricted to view only privileges.&lt;br /&gt;
&lt;br /&gt;
　　• To prevent a file from being checked out by more than one user at a time, use the +l exclusive-open filetype modifier. Files that have the +l filetype modifier can only be opened by one user at a time. Your Perforce administrator can use a special table called the typemap table to automatically specify certain file types as exclusive-open.&lt;br /&gt;
　　&lt;br /&gt;
=====　Streams =====&lt;br /&gt;
　　Perforce streams are structured containers for the files that consist projects, codelines, and components. Streams confer the following benefits:&lt;br /&gt;
&lt;br /&gt;
　　• Ensures a hierarchical approach to branching&lt;br /&gt;
&lt;br /&gt;
　　• Provides an &amp;quot;out of the box&amp;quot; best-practice branching strategy&lt;br /&gt;
&lt;br /&gt;
　　• Provide metadata about the branch hierarchy to the Perforce service&lt;br /&gt;
&lt;br /&gt;
　　• Provide a standard approach to structuring code (stability and hierarchy)&lt;br /&gt;
&lt;br /&gt;
　　• Automate the generation of client workspace views and branch views&lt;br /&gt;
&lt;br /&gt;
　　• Offer a compelling and informative visualization of stream structure and status&lt;br /&gt;
&lt;br /&gt;
　　• Enable you to organize and visualize (bodies of) code.&lt;br /&gt;
&lt;br /&gt;
　　• Provide rules to make development easier.&lt;br /&gt;
　　&lt;br /&gt;
=====　Codeline Management =====&lt;br /&gt;
Codelines are inter-related files that grow together. To organize groups of related files by purpose, branches are created. To move changes between branches, changelists are integrated. To create a snapshot of files in a specific phase, labels can be used.&lt;br /&gt;
　　&lt;br /&gt;
=====　Branching =====&lt;br /&gt;
　　Branching is a method of managing changes between two or more sets of files. Perforce's Inter-File Branching mechanism enables copying of any set of files to a new location in the depot by allowing changes made to one set of files to be copied, or integrated, to the other. The new file set (or codeline) evolves separately from the original files, but changes in either codeline can be propagated to the other by means of integration. Almost all of the version control systems support some form of branching.&lt;br /&gt;
&lt;br /&gt;
　　Merging is actually only one of three possible outcomes of an integration. The others are ignoring (aka &amp;quot;blocking&amp;quot;) and copying (aka &amp;quot;promoting&amp;quot;). Merging is used to keep one set of files up to date with another. For example, a development branch may be kept up to date with its trunk through repeated merging. Ignoring disqualifies changes in one set of files from future integration into another. It is often used when a development branch must be up to date with, and yet divergent from, its trunk. Copying is typically used to promote the content of an up-to-date development branch into a trunk.&lt;br /&gt;
&lt;br /&gt;
'''Some other tools in this category are given below'''&lt;br /&gt;
&lt;br /&gt;
==== AccuRev ====&lt;br /&gt;
[http://www.accurev.com/ AccuRev] is a centralized version control system which uses a client/server model. Communication is performed via TCP/IP using a proprietary protocol. Servers function as team servers, continuous integration servers, or build servers. AccuRev is built around a stream-based architecture in which streams form a hierarchical structure of code changes where parent streams pass on certain properties to child streams. Developers make changes using command line functions, the Java GUI, the web interface, or one of the IDE plug-ins.&lt;br /&gt;
&lt;br /&gt;
Characteristics:&lt;br /&gt;
&lt;br /&gt;
• Streams and parallel development&lt;br /&gt;
&lt;br /&gt;
• Private developer history&lt;br /&gt;
&lt;br /&gt;
• Change packages&lt;br /&gt;
&lt;br /&gt;
• Distributed development&lt;br /&gt;
&lt;br /&gt;
• Automated merging&lt;br /&gt;
&lt;br /&gt;
==== IBM Rational ClearCase ====&lt;br /&gt;
The Rational ClearCase family consists of several software tools for supporting software configuration management (SCM) of source code and other software development assets. It is developed by the Rational Software division of IBM. ClearCase forms the base for configuration management for many large and medium sized businesses and can handle projects with hundreds or thousands of developers.&lt;br /&gt;
A part of Rational ClearCase is revision control system, which is a feature for end users.&lt;br /&gt;
&lt;br /&gt;
ClearCase supports two kinds of use models, UCM (Unified Change Management), and base ClearCase. UCM provides an out-of-the-box model while base ClearCase provides a basic infrastructure (upon which UCM is built). Both can be configured to support a wide variety of needs. UCM is part of RUP (Rational Unified Process) and therefore all process templates and roles can be used from RUP.&lt;br /&gt;
&lt;br /&gt;
'''Features:'''&lt;br /&gt;
&lt;br /&gt;
• Build auditing&lt;br /&gt;
&lt;br /&gt;
• VOB (Versioned Object Base)&lt;br /&gt;
&lt;br /&gt;
• Configuration Record&lt;br /&gt;
&lt;br /&gt;
• Build Avoidance&lt;br /&gt;
&lt;br /&gt;
• Unix/Windows Interoperability&lt;br /&gt;
&lt;br /&gt;
• Integration With Other Products&lt;br /&gt;
&lt;br /&gt;
• Space Saving&lt;br /&gt;
&lt;br /&gt;
'''Weaknesses:'''&lt;br /&gt;
&lt;br /&gt;
• Speed&lt;br /&gt;
&lt;br /&gt;
• Sensitivity to network problems&lt;br /&gt;
&lt;br /&gt;
=== Local Data Model ===&lt;br /&gt;
In the local-only approach, all developers must use the same computer system. These software often manage single files individually and are largely replaced or embedded within newer software. This data model is the grandfather of all the modern version control softwares. These are the very first softwares for version control that were implemented in the late 1970's. Technological and software advances have rendered these practically useless but certain legacy systems still use these due to the hardware and software limitations.&lt;br /&gt;
&lt;br /&gt;
==== Source Code Control System (SCCS) ====&lt;br /&gt;
　　Source Code Control System (SCCS) is an early revision control system, geared toward program source code and other text files. It was originally developed in SNOBOL at Bell Labs in 1972 by Marc Rochkind for an IBM System/370 computer running OS/360 MVT. SCCS was the dominant version control system for Unix until the release of the Revision Control System (RCS)[dubious – discuss]. Today, SCCS is generally considered obsolete. However, its file format is still used internally by a few other revision control programs, including BitKeeper and TeamWare. The latter is a frontend to SCCS. Sablime has been developed from a modified version of SCCS but uses a history file format that is incompatible with SCCS. The SCCS file format uses a storage technique called interleaved deltas (or the weave). This storage technique is now considered by many revision control system developers as foundational to advanced merging and versioning techniques, such as the &amp;quot;Precise Codeville&amp;quot; (&amp;quot;pcdv&amp;quot;) merge.&lt;br /&gt;
　　&lt;br /&gt;
==== Revision Control System (RCS) ====&lt;br /&gt;
The Revision Control System (RCS) is a software implementation of revision control that automates the storing, retrieval, logging, identification, and merging of revisions. RCS is useful for text that is revised frequently, for example programs, documentation, procedural graphics, papers, and form letters. RCS is also capable of handling binary files, though with reduced efficiency. Revisions are stored with the aid of the diff utility.&lt;br /&gt;
&lt;br /&gt;
This came into existency in 1982 and gave the version control systems a new dimension. It was the best VCS for the single user system, where all the files related to a project are in a single system. RCS just locks a single file that is being used and doesn't lock the entire project which is computationally cheaper.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. [http://www.oss-watch.ac.uk/resources/versioncontrol Version Control Tools]&lt;br /&gt;
&lt;br /&gt;
2. [http://www.mediamosa.org/content/source-code DVS]&lt;br /&gt;
&lt;br /&gt;
3. [http://blogs.atlassian.com/2012/02/version-control-centralized-dvcs/ Distributed Version Control]&lt;br /&gt;
&lt;br /&gt;
4. [http://git-scm.com/ Git]&lt;br /&gt;
&lt;br /&gt;
5. [http://gitready.com/beginner/2009/02/17/how-git-stores-your-data.html GitReady]&lt;br /&gt;
&lt;br /&gt;
6. [https://wiki.archlinux.org/index.php/Git‎ Archlinux] &lt;br /&gt;
&lt;br /&gt;
7. [http://stackoverflow.com/questions/8198105/how-git-stores-files StackOverflow]&lt;br /&gt;
&lt;br /&gt;
8. [http://en.wikipedia.org Wikipedia]&lt;br /&gt;
&lt;br /&gt;
9. [http://www.perforce.com/perforce/doc.current/manuals/p4v-gs/p4v-gs.pdf Perforce documentation and manuals ‎]&lt;/div&gt;</summary>
		<author><name>Abhutan</name></author>
	</entry>
</feed>