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

Space - Diana #30

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

Space - Diana #30

wants to merge 1 commit into from

Conversation

dnguye2
Copy link

@dnguye2 dnguye2 commented Feb 10, 2020

Assignment Submission: Ride Share

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? At first, it was a master array then 2 hashes. I changed it to a master hash > hash > values with arrays because it was easier for me to access any level of the data.
What was your strategy for going through the data structure and gathering information? Figuring out how to get access to the question then the code to get the info for one single driver.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? When calculating the highest earner or highly rated, it was necessary to have a variable to iterate through the data. It was useful because creating the code to iterate through the data was easy to do an guided me on how to do it.
What kinds of iteration did you use? Did you use .map? If so, when? If not, why, or when would be a good opportunity to use it? I used '.each' and '.map' . I used '.map' for the first three questions as it was slightly shorter and more intuitive for me than using '.each'.
Were some calculations easier than others? Why? Yes, the first and second question was the easiest since it was fairly simple. For 3, it was harder because it involved figuring out multiple operations because it was an average while making sure to correctly access the data.

@dnguye2 dnguye2 changed the title Create rideshare_nguyen.rb Space - Diana Feb 10, 2020
@dHelmgren
Copy link

dHelmgren commented Feb 11, 2020

Ride Share

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly creates, reads, and modifies variables ✔️
Correctly creates and accesses arrays ✔️
Correctly creates and accesses hashes ✔️
Reasonably organizes large amounts of related data into nested arrays and hashes ✔️
Correctly iterates through a nested data structure using loops and/or Enumerable methods ✔️
Reasonably organizes small pieces of code into methods, and calls/invokes those methods

Functional Requirements

Functional Requirement yes/no
To the terminal, the program outputs the correct number of rides each driver has given ✔️
... outputs the total amount of money each driver has made ✔️
... outputs the average rating for each driver ✔️
... outputs which driver made the most money ✔️
... outputs which driver has the highest average rating ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 4+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 2-3 in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0,1 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Elegant/Clever

Comment on lines +18 to +21
date_of_ride: ["3rd Feb 2016", "3rd Feb 2016", "5th Feb 2016"],
rating: [3, 4, 2],
money_earned: [10, 30, 45],
rider_of_drive: ["RD0003", "RD0015", "RD0003"]

Choose a reason for hiding this comment

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

If you are going to align these keys and values like this, indent these lines. It makes it more clear what is and isn't in each hash in rides

Comment on lines +49 to +61
# (1) Number of rides each driver has given
# Based off of the "date_of_rides" array, finding the
# length of this array will give the total amount of rides

# Strategy - first try to find amount for one driver first,
# then iterate.
# Came up with the following code for a single driver
## puts "Driver 1 gave #{(rides[:DR0001][:date_of_ride]).length} rides"

# To iterate the above code to give all drivers amount of rides
# use the ".map" enumerable
# to access the correct array, must include both key (driver) and value (data)
# as arguments for the block

Choose a reason for hiding this comment

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

this is pretty big for a standard comment! Can you sum it up in 1-2 lines instead? Comments work best as an in-line tool, snug with the code it's giving info on.

Comment on lines +84 to +86
rides.map {|driver, data|
puts "Driver #{driver} made a total of: $#{(data[:money_earned]).inject(:+)}"
}

Choose a reason for hiding this comment

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

This is SUPER elegant!

# When iterating, wanted a nonrepeating decimal and used sprintf("%.2f", <average rating>)
# to output only 2 decimal places

rides.map {|driver, data|

Choose a reason for hiding this comment

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

Do you really want map here? What is map doing that each can't?

highest_earnings = 0.0
highest_earner = " "

rides.each { |driver, data|

Choose a reason for hiding this comment

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

You iterate over this hash a lot. Is there a way to keep this code organized while reducing the number of times you loop over rides? Perhaps methods could help.

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