Skip to content

Leaves - Tiffany#31

Open
TiffanyChio wants to merge 3 commits intoAda-C12:masterfrom
TiffanyChio:master
Open

Leaves - Tiffany#31
TiffanyChio wants to merge 3 commits intoAda-C12:masterfrom
TiffanyChio:master

Conversation

@TiffanyChio
Copy link

ride share

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? Initially I wanted my data structure to be an array of hashes where each each element of the array represented one trip, and the hash keys would represent each category of data. I thought this best transcribed the csv file as-is and would be the best way to structure the data regardless of what analysis needed to be performed on the data. Eventually I went a hash structure instead with driver IDs as the keys and an array of hashes as the value. This structure better allowed me to analyze the data with the questions asked in part 4 in mind. All the questions are driver-centric so it made my work the easiest if I structured the data around the drivers.
What was your strategy for going through the data structure and gathering information? The questions I needed to answer can be broken down into two parts: questions about each individual driver and questions about the “max” or “highest” within the data set. I looped through each driver’s data first to calculate and print information pertaining to the individual driver. Within the same loop, I stored the data I would later need to analyze in hashes. Calculations for maxes/mins over an entire data set cannot be analyzed until the values are collected first. I found the highest earner and the driver with the highest average rating via Ennumerables but the idea is that the program is looping through the calculated hashes to find max values and their associated keys.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I stored max earning in a variable because I referenced it more than once. The first time as an argument in the find_corresponding_hash_keys method and a second time within puts when the output was printed. Storing the value in a variable made the code clearer and more readable as otherwise the lines of would be very long with a lot of nesting and method calls.
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 more Ennumerables than iteration loops. Ennumerables are iterating under the hood too and the ones I used included .max, .select, and .sum.

I used each loops when trying to calculate and store data for each driver and when calculating how much drivers earned on each particular date. And I used each_with_index when trying to convert arrays into grammatically correct strings. I did not use .map in place of the each loop that iterated through the driver data because the content of the loop was very long and I wanted to return more than one piece of information (total earnings and average rating) as their own separate hashes to better take advantage of Ennumerables for later calculations. I also did not use .map in place of the each loop that iterated to find how much each driver made per day because I did not need to perform the same calculation on each element of my array. In some cases where rides occurred on the same day, I needed to add the values of several elements together. Map will preserve the structure of the input.

I could have used .map if I split up my rides.each loop (looping through each driver information) into several sections but it was easier and more intuitive for me to code it as on large each loop instead.
Were some calculations easier than others? Why? Calculation asking for sum and maximums were easy because Ennumerables existed to quickly code for a solution. The optional portion about finding the day on which each driver earned the highest amount was more difficult because it involved comparing the dates prior to performing calculations. And I didn’t have an Ennumerable ready to go for that.

@beccaelenzil
Copy link

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions
Readable code with consistent indentation and reasonable code style
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 | Nice work on this project. It was clever to write some methods that make the enumerable methods work for you in the context of hashes. You code is clear and readable. The organization of your data structure works well. See one inline comment for a suggestion of how to use the .join method to make your code more succinct.

@beccaelenzil
Copy link

beccaelenzil commented Aug 14, 2019

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions yes
Readable code with consistent indentation and reasonable code style yes
Outputs the correct number of rides each driver has given yes
Outputs the total amount of money each driver has made yes
Outputs the average rating for each driver yes
Outputs which driver made the most money yes
Outputs which driver has the highest average rating yes
Overall Nice work on this project. It was clever to write some methods that make the enumerable methods work for you in the context of hashes. You code is clear and readable. The organization of your data structure works well. See one inline comment for a suggestion of how to use the .join method to make your code more succinct.

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