-
Notifications
You must be signed in to change notification settings - Fork 37
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
Queues- Danielle Birbal - Ride-Share-Two #20
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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