Queues- Danielle Birbal - Ride-Share-Two - #20
Conversation
Ride ShareWhat We're Looking For
Great job! Code is clear and readable, and tests cover almost everything I was looking for. Keep up the good work! |
|
|
||
| DRIVER_INFO.each do |line| | ||
| next unless line[0].to_i == id | ||
| @driver_id = id |
There was a problem hiding this comment.
I like the idea here - being able to initialize a driver with just the ID and have the program fill in the details is very convenient. However, I'm a little worried about the efficiency of looping through the whole DRIVER_INFO array here. In particular, if Driver.all creates a new Driver for every ID in DRIVER_INFO, then Driver.all ends up being O(n^2).
It might be you could chose a different data structure to get around this. I'll leave that up to you.
| end | ||
|
|
||
| def avg_rating | ||
| @driver_trips = trips |
There was a problem hiding this comment.
I'm curious why you chose to use an instance variable here. Seems like the trips don't need to persist long term, only for the duration of the method, which to me indicates that a local variable might be a better choice.
| end | ||
| it 'Calculates the average rating correctly' do | ||
| new_driver.avg_rating.must_equal 3.4 | ||
| end |
There was a problem hiding this comment.
What happens if the driver hasn't made any trips yet?
| describe RideShare::Driver do | ||
| let(:new_driver) { RideShare::Driver.new(18) } | ||
|
|
||
| describe 'initialize' do |
There was a problem hiding this comment.
Good organization - the nested describes make this code much easier to read.
| new_rider.previous_drivers[0].driver_id.must_equal 69 | ||
| new_rider.previous_drivers[0].name.must_equal 'Ernesto Torp' | ||
| new_rider.previous_drivers[0].vin.must_equal 'RF4BPA803R4AACTR1' | ||
| end |
There was a problem hiding this comment.
As with Driver.average_rating, what happens if the rider hasn't taken any trips?
Ride Share
Congratulations! You're submitting your assignment!
Comprehension Questions