- Explain what code is doing
- Refactor for clarity and readability
Using the goals below, choose a challenge solution from Class Warfare, Validate a Credit Card Number. This can be anyone's solution, but if you notice there's a lot of room for improvement with your own code, start with that. Find other's solutions by browsing the branches (just like you would to comment on a random person's solution).
Paste the original unrefactored code in your gist, and as you refactor, make notes of the changes you are making to achieve optimal readability. Include those notes along with the refactored version in your my_solution.rb file.
- Eliminate repetition by using looping and branching wisely
- Complex operations are decomposed into constituent parts
- Descriptive names for methods, variables, classes, and modules
- Methods are small and behavior is obvious
- Minimizes need for comments because the code tells you what it is doing
- Code is formatted with proper indentation for optimal readability
Release 0: Write assert statements
Take the driver code and turn it into assert statments with valid and invalid card numbers.
Release 1: Pseudocode
Comment each chunk of code in the original solution
Release 3: Refactor the solution for readability
Release 4: Reflect
Release 6: Review
Write feedback for at least two other solutions!