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

Sockets - Riyo #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Sockets - Riyo #38

wants to merge 1 commit into from

Conversation

RPerry
Copy link

@RPerry RPerry commented Feb 8, 2019

Portmanteau Generator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What went well in your code style, such as indentation, spacing, variable names, readability, etc.? What was lacking? I think my readability and indentation was done well, although I'm not sure if I should put more spacing between my code and comments. My variable names are not very descriptive and can be a bit repetitive and I will work on naming variables in a way that makes their use more obvious.
How did creating the is_vowel? method affect your project? It made my code cleaner and made my run_generator method shorter because I did not need to repeatedly write out an if statements to determine if a letter was a vowel.
What was your strategy for getting the correct set of letters from the first word into the portmanteau? I used .each_char to iterate over each letter and push the 'true' or 'false' results into an array. I then determined the index of each occurrence of a vowel in the array using .select and then used .max to find the highest index, which would be the last occurrence of a vowel in the word. I then used a range to add only the letters up to but not including the last vowel, using that highest index into a variable storing the portmanteau. If there were no vowels in the word, the whole word is stored in the variable.
What was your strategy for validating against inputs under 2 characters? I used an until loop that continues to ask for another input attempt if the word they submit is shorter than 2 characters.
In the next project, what would you change about your process? What would you keep doing? Writing pseudocode before attempting to actually write the code was very helpful in working out the logic of how the portmanteau would be created and I will continue to that for future projects. I would change how long I continued to attempt solutions that did not work before I tried something new.

@dHelmgren
Copy link

Portmanteau Generator

What We're Looking For

Feature Feedback
Readable code with consistent indentation Generally good, but see my comment
Practices using variables appropriately Yes!
Practices using conditionals appropriately Yes
Practices iteration appropriately Yes
Practices using custom methods appropriately Good work, there might be even more places where you could use helper methods!
Program validates against input under 2 characters yes
Takes in two inputs and creates a portmanteau yes

def run_generator
# Gets input from user for first word, will not accept fewer than two letters
puts "What's the first word you would like to combine?: "
word_a = gets.chomp.downcase

Choose a reason for hiding this comment

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

good work making this work with lowercase!

puts "Please try again and enter your second word: "
word_b = gets.chomp.downcase
end
puts "The first word is #{word_a}"

Choose a reason for hiding this comment

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

One general changed I'd look for in your code is more whitespace! It's good to group code by adding blank lines so that we can tell what sections represent a "single thought". Convention in most workspaces is to have whitespace before and/or after loops and method declarations.

word1_vowels = []
word_a.each_char do |letter|
word1 << is_vowel?(letter)
end

Choose a reason for hiding this comment

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

We talked about this a little in class, but this solution while effective, isn't efficient. It might be better to discover the index by counting backwards through the array until we find the first vowel. If you have more questions about this, bother me!

return word
end

puts "Here is your portmanteau: #{run_generator}"

Choose a reason for hiding this comment

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

I would do this differently. I would have this puts statement at the end of the run_generator method, and I would have just called run_generator on this line instead.

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