Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports - Elle & Sopheary #20

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

dev-elle-up
Copy link

@dev-elle-up dev-elle-up commented Feb 23, 2019

Adagrams

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the components that make up a method? The components of a method are the "def" keyword, method signature (including the method name and any arguments), code block, and end keyword.
What are the advantages of using git when collaboratively working on one code base? Git enables you to track changes and go back to previous states of the code if something breaks in the future. If the code is stored on a remote repository, multiple team members can share the project files by cloning the project to their local machines. They can each work on different parts of the code, or work on it at different times, and then merge changes efficiently.
What kind of relationship did you and your pair have with the unit tests? We ran the unit tests frequently after building each method. We used the resulting failures and errors to fix our code. We did this one error at a time, running the spec file after each change.
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? Yes! It uses .map and .min_by. ".map" was helpful to quickly and efficiently create a new array with all the words having the max score. We could then iterate through that array to find the winning word. ".min_by" let us find the highest scoring word with the fewest letters in case of a tie.
What was one method you and your pair used to debug code? Throughout the "uses_available_letters" method, we entered several puts statements which showed us what was happening to the arrays as the code ran. This was essential for our success.
What are two discussion points that you and your pair discussed when giving/receiving feedback from each other that you would be willing to share? 1) Switching every 20 minutes was frustrating and anxiety inducing for both of us because it broke our rhythm just as we would get into a groove. When we adjusted our period of time to switch between driver and navigator to be longer (30 minutes with an optional extra 5 minutes to finish a thought) worked much better. 2) We liked that we both learned things from each other.

@tildeee
Copy link

tildeee commented Mar 4, 2019

Adagrams

What We're Looking For

Feature Feedback
General
Answered comprehension questions x
Both teammates contributed to the codebase x
Small commits with meaningful commit messages x, in general, we would like have commit messages that described the changes, rather than "wave 2" etc.
Code Requirements
draw_letters method x
Uses appropriate data structure to store the letter distribution x
All tests for draw_letters pass x
uses_available_letters? method x
All tests for uses_available_letters? pass x
score_word method x
Uses appropriate data structure to store the letter scores x
All tests for score_word pass x
highest_score_from method x
Appropriately handles edge cases for tie-breaking logic x
All tests for highest_score_from pass x
Overall

Hi Elle and Sopheary! Good work on this project!

Your submitted code is good code style, and proves to me that the iteration and use of Enumerable methods is solid. Great job with getting all of the implementation done well and correctly

I have a few comments about some things like global variables and a helpful method to use in the future to make your code slimmer

That being said, great work on this project overall!

quantity.times do
$letter_pool << letter.to_s
end
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You all populated a variable representing the letter pool as a global variable! In some ways, this makes sense, but in general, we'll avoid using global variables. Our hope was top put the above few lines within the draw_letters method, since that's the only time you'll use this variable.

5 => ["K"],
8 => ["J", "X"],
10 => ["Q", "Z"],
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my previous comment: we'll try to avoid using global variables in the future, and the only method that uses this variable $letter_scores is in the score_word method, so we could move this variable there.

# Make a copy of the input array and keep the original
# array unchanged. The original input needs to remain in tact so
# that Ruby can continue to iterate through it the
# uses_available_letters methods.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great use of a comment: to add detail about something that feels a little weird and needs explanation!

break
end
hand_index += 1
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of each_with_index! It seems to me that the purpose of this loop is to find the index of the letter you're looking for. There is a method that works on strings for this: letters_in_hand.index(letter)... which will give you the first index of a matching element (letter) in the array (letters_in_hand). It's assuming to find the first index of a matching element, but you can safely make that assumption since you're iterating through input in order :) (Actually, it kind of feels like you implemented the .index method, so great job on that :D)

hand_index += 1
end

letters_in_hand.delete_at(hand_index)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In conjunction with what I mentioned above, you could replace this line with: letters_in_hand.delete_at(letters_in_hand.index(letter))

break
end
end
input_copy.delete_at(i)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop ends up solving a similar problem to above, and therefore, has a similar solution. With that, if you wanted to use the .index method, you could replace this line with: input_copy.delete_at(input_copy.index(letter))


winning_word[:score] = max_score.to_i
return winning_word
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method ended up being pretty long -- if methods get this long, feel free to break sections up into smaller helper methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants