Skip to content

Sockets - Cyndi#33

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

Sockets - Cyndi#33
cyndilopez wants to merge 1 commit intoAda-C11:masterfrom
cyndilopez:master

Conversation

@cyndilopez
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? It looked like a hash of driver IDs with each driver ID's value set to an array of hashes. The hashes were comprised of detailed ride information, such as cost, rider_ID, etc. It did not change over time
What was your strategy for going through the data structure and gathering information? I iterated through the data structure and extracted the key and values, which had the necessary information.
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 ride information as a variable in order to use other methods on it to obtain the necessary information. In order to extract the ride information, I was also required to store it as a variable.
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 the .each mostly. However, I also used .map in order to create an array of hashes from the data structure. I used this new array of hashes to store information I newly calculated.
Were some calculations easier than others? Why? Some calculations had methods associated with them which made it easier to calculate.

@cyndilopez cyndilopez changed the title Rename worksheet.rb to worksheetv2.rb Sockets - Cyndi Feb 19, 2019
@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! In general you code is functional and well-written. However, it often feels like you're trying to cram too many things onto one line of code. This can be tempting, but remember that one of the main functions of a piece of code is to be read by other humans. Lines in a file are cheap but developer time is expensive, so making your code a little more verbose to increase readability is definitely worthwhile. Other than that things look good - keep up the hard work!

# - the average rating for each driver
drivers.each do |driver, records|
avg_rating_driver = ((records.sum { |x| x[:RATING] }).to_f / records.length).round(2)
puts "Driver #{driver} has an average rating of #{avg_rating_driver}"

Choose a reason for hiding this comment

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

There's a lot going on on line 69. I might break this up across multiple lines, possibly using an intermediate variable.

# - Which driver made the most money?
dd = drivers.map do |driver, records|
{name: driver, totalcost: records.sum { |x| x[:COST] }}
end

Choose a reason for hiding this comment

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

dd is not a great variable name - as a newcomer to this code, I have no idea what that contains. You should use something more descriptive, such as income_by_driver.

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