Skip to content

Sockets - Evelynn#38

Open
evelynnkaplan wants to merge 1 commit intoAda-C11:masterfrom
evelynnkaplan:master
Open

Sockets - Evelynn#38
evelynnkaplan wants to merge 1 commit intoAda-C11:masterfrom
evelynnkaplan:master

Conversation

@evelynnkaplan
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? The entire time, my data structure had 4 layers: an array for all the rides, nesting one hash for each driver. Each driver's hash had a value that nested an array with nested hashes of info about each ride the driver gave. It didn't change over time because I looked ahead and saw the assignment's questions were driver-focused, so I wanted my data structure to be driver-focused.
What was your strategy for going through the data structure and gathering information? I used two each loops. The first looped through the all_rides array and stored the requested statistics about each driver into hashes nested in an array called driver_data. During the second each loop, I iterated over the information in driver_data to find the drivers who made the most money and had the highest rating.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? It was necessary to store the driver's total rides because later that was used to calculate the driver's average rating.
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 loops. I didn't use map because I never needed to create an array that was similar to another array with a consistent change.
Were some calculations easier than others? Why? Some calculations were slightly easier because they required data that wasn't nested as deeply. For example, I calculated a driver's total rides just by the length of that driver's "rides" array. The "rides" array was only in the 3rd layer. Other calculations needed to be made in the 4th layer.

@droberts-sea
Copy link

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions yes
Readable code with consistent indentation and reasonable code style mostly - see inline
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

Good job overall! While I've left a few inline comments below, your code works well and it is clear to me that the learning goals around working with enumerables and complex data structures were met. Keep up the hard work!

driver_data = [] # This array will store hashes that will store data throughout the upcoming calculations.
all_rides.each do |d|
driver = {} # Stores each driver's stats
driver["driver id"] = d["driver id"]

Choose a reason for hiding this comment

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

Similar to the feedback I left on Portmanteau generator, this code would be much easier to read if you were to break it up using blank lines. Not sure if that feedback came in time to help here, but I'll be watching for this on Adagrams.

"driver id" => "DR0001",
"rides" => [
{
"date" => "3rd Feb 2016",

Choose a reason for hiding this comment

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

In general, in Ruby it is considered good style to use symbols as the keys in hashes.

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