Skip to content
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

Maddie Shields & Hayden Williams - Edges - oo - RideShare #3

Open
wants to merge 77 commits into
base: master
Choose a base branch
from

Conversation

madaleines
Copy link

OO Ride Share

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a design decision you had to make when working on this project. What options were you considering? What helped you make your final decision? A design decision made was in the trip dispatcher and we assign the "first_available_driver" and how that was a method which called upon multiple helper methods to determine assigning a driver who has no trips, otherwise the driver who hadn't taken a trip recently, and lastly if none were available to Raise an error. The alternative would have been keeping the code in one block which would have made it hard to read.
Describe any examples of composition that you encountered in this project, if any Instead of having all functionality in the TripDispatcher class, we can see it broken up in multiple classes with respect to Driver, User and Trip. When the TripDispatcher creates a new Trip it can call upon each class for the desired functionality.
Describe the relationship between User and Driver User is the parent class to Driver. Driver inherits the qualities of a User as well needing a vehicle_id, driven_trips array, and status. A passenger could potentially be a driver as well and have the same id.
Describe a nominal test that you wrote for this assignment. All methods which calculated totals needed testing to make sure they returned a float and a specific amount.
Describe an edge case test that you wrote for this assignment A driver not being able to drive themselves
Describe a concept that you/your pair gained more clarity on as you worked on this assignment We got to a part of the request_trip method and I began getting confused about adding a trip to the driver's driven trips, the passenger trips, and the trips array which Hayden helped break up the relationships to me. Hayden received more insight on how to approach TDD.
What are two discussion points that you and your pair discussed when giving/receiving feedback from each other that you would be willing to share? We were both very direct and also able to recognize quickly that feedback received was not personal. This helped us push through fixing problems as they arose fairly quickly.

madaleines and others added 30 commits August 27, 2018 15:03
haydenwalls and others added 28 commits August 29, 2018 16:08
…ver's collection of trips and sets driver's status to :UNAVAILABLE
…ding first available driver prepping for wave 4
@droberts-sea
Copy link

Ride Share

What We're Looking For

Feature Feedback
Baseline
Used Git Regularly yes
Answer comprehension questions yes
Wave 1
Appropriate use of Ruby's Date yes
Trip has a helper method to calculate duration yes
User (passenger) has a method to calculate total cost of all trips yes
Tests for wave 1 missing some edge cases - see inline
Wave 2
Driver inherits from User yes
Driver has add_driven_trip method yes
Driver has method to calculate average rating yes
Driver has method to calculate net expenditures and it uses super yes
Driver has a method to calculate total revenue yes
Tests for wave 2 see inline
Wave 3
TripDispatcher has a new method to create trips yes
creating a trip in TripDispatcher relies on methods in Driver and User (passenger) to modify their own attributes yes
Complex logic was correctly implemented yes
Tests for request_trip yes - see inline
Methods from wave 1 and 2 handle incomplete trips no
Tests for wave 1 and 2 methods with incomplete trips no
Wave 4 (Optional)
TripDispatcher now assigns trips to either the newest driver (no trips), or the driver who has not driven in the longest time yes
Appropriate helper methods were made to help with complex logic yes
Tests for wave 4 yes - see inline
Overall

Good job overall. Your product code is strong, and it's clear you have a good understanding of the problem. However, I see room for improvement around testing. This manifests in two big ways:

  • Missing edge cases (user with no trips, or with an incomplete trip)
  • Unclear and unverified assumptions (driver 8 would normally be assigned to this trip)

However, this is the first time you've had to write a substantial portion of the tests, so I'm particularly concerned (especially given how last week went in general). I've tried to call out missing tests and places where things could be improved inline below. Please keep these in mind as you work on the hotel project this week, and keep up the hard work!

end
raise ArgumentError.new("Invalid rating #{@rating}") if @rating != nil && (@rating > 5 || @rating < 1)

raise ArgumentError.new("Start time cannot be greater than End time") if @end_time != nil && (@end_time < @start_time)

Choose a reason for hiding this comment

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

For both these lines, I think the postfix conditional makes the code harder to read, not easier. A good rule of thumb is to keep lines shorter than 80 characters, but even that is pushing it.

it "raises an error if end time precedes start time" do
start_time = Time.parse('2015-05-20T12:14:00+00:00')
end_time = start_time - 25 * 60 # 25 minutes
trip_data = {

Choose a reason for hiding this comment

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

What does this method do for an in-progress trip (nil end time)?

describe '#net_expenditures method' do
it 'calculates the total expenditures by a User' do
expect(@user.net_expenditures).must_equal 33.70
end

Choose a reason for hiding this comment

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

You're missing a couple of interesting cases for both these new User methods:

  • What happens if the user has no trips?
  • What happens if the user has an incomplete trip?

def net_expenditures
total_expenditures = 0
@trips.each do |trip|
total_expenditures += trip.cost

Choose a reason for hiding this comment

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

This doesn't handle incomplete trips (end time, cost and rating are nil)!


STATUS_OPTIONS = [:AVAILABLE, :UNAVAILABLE]
DRIVERS_CUT = 0.8
FEE = 1.65

Choose a reason for hiding this comment

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

Great use of constants to hold these values!


find_most_recent_trips = available_drivers.map do |driver|
driver.driven_trips.max_by(&:end_time)
end

Choose a reason for hiding this comment

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

The logic on line 117 might work well as a helper method in Driver, something like Driver.most_recent_driven_trip

available_drivers = @dispatcher.generate_available_drivers
expect(available_drivers).must_be_kind_of Array
expect(available_drivers.first.status).must_equal :AVAILABLE
expect(available_drivers.last.status).must_equal :AVAILABLE

Choose a reason for hiding this comment

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

I would go further than just checking the first and the last here: iterate through the list and check each one.

it "returns an array of :AVAILABLE drivers that aren't the Passenger" do
available_drivers = @dispatcher.check_drivers_not_passenger?(2)
expect(available_drivers).must_be_kind_of Array

Choose a reason for hiding this comment

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

Is driver 2 usually available?

it "Assigns the first :AVAILABLE driver with no driven trips to a new Trip" do
driver = @requested_trip.driver
expect(driver).must_be_instance_of RideShare::Driver
expect(driver.driven_trips.length).must_equal 1

Choose a reason for hiding this comment

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

None of these tests answer the question: what do these helper methods do if no suitable driver is available?

passenger_id = new_trip.passenger.id

expect(driver_id).wont_equal passenger_id
expect(driver_id).must_equal 5

Choose a reason for hiding this comment

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

Would it normally assign driver 8 in this case? How do you know? How could you make it clear to the reader of this test?

A comment explicitly calling out this assumption would be a good start, but even better would be some assertions before your code that verify the expected behavior. For example, you might call @dispatcher.first_available_driver with a different passenger ID, and make sure that you get driver 8 back.

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.

3 participants