CSC/ECE 517 Spring 2015/oss E1506 SYZ

From Expertiza_Wiki
Revision as of 19:58, 21 March 2015 by Zhu6 (talk | contribs) (→‎Todo List)
Jump to navigation Jump to search

E1506: Refactoring, testing and new features related to “users”

Overview

Code refactoring

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior<ref>Refactoring</ref>. Refactoring adds to the value of any program that has at least one of the following shortcomings<ref>Benefits of Code Refactoring Michael Hunger. Oct. 25, 2000</ref>:

  • Programs that are hard to read are hard to modify;
  • Programs that have duplicate logic are hard to modify;
  • Programs that require additional behavior that requires you to change running code are hard to modify;
  • Programs with complex conditional logic are hard to modify.

Rspec

RSpec is a behavior-driven development (BDD) framework for the Ruby programming language, inspired by JBehave. It contains its own mocking framework that is fully integrated into the framework based upon JMock. The framework can be considered a domain-specific language (DSL) and resembles a natural language specification<ref>Rspec</ref>.

Object-oriented Design Principles

Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic<ref>Margaret Rouse. object-oriented programming (OOP) definition. Aug 3, 2008</ref>. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. Though an Object oriented language provides us with highly useful and important programming concepts like Inheritance, Polymorphism, Abstraction and Encapsulation which definitely makes the code more efficient, it is equally important to have the knowledge of using them in the code. Object Oriented Design Principles are core of OOPS programming<ref>Javin Paul. Blogspot. March 3, 2012</ref>. It is important to know these design principles, to create clean and modular design. There are many design principles that help us to create clean and efficient code.


Project Resources

Todo List

Related files: users_controller.rb, participants_controller.rb, user.rb, users/show.html.erb

  • Find the un-called methods if any and delete them. [done]
  • Change the Rails 2 syntax to Rails 4 style.
  • Refactor users_controller.rb
    • Change the white space for the second harf of this file, starts at “def edit”. [done]
    • Separate the “paginate_list” method into two methods. The search method should be in model and the paginating method should be in the controller. [done]
  • New feature: delete users
    • A user can be deleted if (s)he has not participated in an assignment. [done]
    • If the user is participating in an assignment, the system will ask, “User is participating in k assignments. Delete as a participant in these assignment(s)?” [done]
    • If the user has submitted or reviewed in any of these assignments, the system will say the user cannot be deleted, but offer to rename the user account to <current_account_name>_hidden.
      • rename (javascript calling update method in users_controller.rb) [done]
      • different users have different delete methods. [done]
    • If the person trying to delete does not want to rename the account, the system will just say that the user can’t be deleted. [done]
    • Write tests (with Rspec) for this feature.[done]
  • Testing feature: search for users
    • In rails 4 branch, admins can search for the users with 1) users’ login names 2) users’ last or first names and 3) users’ emails. Please write tests (with Rspec) for this feature [done]

References

<references/>