Skip to content

Space-Hala Haddad and Becca Roach#12

Open
halahaddad1 wants to merge 27 commits into
Ada-C13:masterfrom
halahaddad1:master
Open

Space-Hala Haddad and Becca Roach#12
halahaddad1 wants to merge 27 commits into
Ada-C13:masterfrom
halahaddad1:master

Conversation

@halahaddad1

Copy link
Copy Markdown

Assignment Submission: OO Ride Share

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
How did getting up to speed on the existing codebase go? If it went well, what worked? If it didn't go well, what will you do differently next time? It took a whole day to go through the database, we did not move forward with the waves before we had a working understanding of the database and tests
What inheritance relations exist between classes? CsvRecord is the parent class of classes : Passenger, Trip and Driver
What composition relations exist between classes? TripDispatcher has Passengers, Trips and Drivers
Describe a decision you had to make when working on this project. What options were you considering? What helped you make your final decision? One was deciding how to calculate the total revenue of a driver, the design document had mentioned extracting $1.65 from a trip, but we decided to make a decision to only extract that amount if the trip cost was over $1.65. we considered doubling that number, or at least having a minimum threshold before subtracting that amount, but what helped in our final decision was knowing that we don't have all the information needed to make that business logic!
Give an example of a template method that you implemented for this assignment The load_all method inherits .from_csv method and that is the way all the classes accessed data from the CSV files
Give an example of a nominal test that you wrote for this assignment We wrote a test in trip_dispatcher that made sure the driver picked was the most eligible driver according to "wave 4" requirements. Another example is the total_time_spent for a passenger's trip was accurate
Give an example of an edge case test that you wrote for this assignment We wrote a few tests that checked if input was less than 1 or nil to verify id numbers or passenger id numbers
What is a concept that you gained more clarity on as you worked on this assignment Tdd and writing tests in general, also debugging!

@kaidamasaki

Copy link
Copy Markdown

OO Ride Share

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
The code demonstrates individual learning about Time and the responsibility of Trip.from_csv, and uses Time.parse in Trip.from_csv ✔️
The code demonstrates breaking out complex logic in helper methods, such as making a helper method in Trip to calculate duration ✔️
There are tests for the nominal cases for the Passenger#net_expenditures and Passenger#total_time_spent ✔️
There is at least one edge case test for either Passenger#net_expenditures or Passenger#total_time_spent testing if the passenger has no trips No edge case tests.
Practices inheritence. Driver inherits from CsvRecord, and implements from_csv ✔️
Employs problem-solving and implements Driver#average_rating and Driver#total_revenue ✔️
Implements the TripDispatcher#request_trip, which creates an instance of Trip with a driver and passenger, adds the new trip to @trips, and changes the status of the driver ✔️ (Though the status is switched in pick_best_driver which is non-obvious at first. I'd recommend against mixing a query with a command like this. We're talking about this tomorrow.)
Practices composition. In TripDispatcher#request_trip, the driver gets connected to the new trip, the passenger gets connected to the new trip ✔️
Practices git with at least 10 small commits and meaningful commit messages ✔️

Testing Requirements

Testing Requirement yes/no
There is reasonable test coverage for wave 1, and all wave 1 tests pass ✔️
There is reasonable test coverage for wave 2, and all wave 2 tests pass ✔️
Wave 3: Tests in wave 1 and wave 2 explicitly test that only completed trips should be calculated (and ignore in-progress trips) No.
There is reasonable test coverage for TripDispatcher#request_trip, and all tests pass ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 8+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 6+ in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0-5 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

@kaidamasaki kaidamasaki left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job. Here are some tips to clean things up. :)

Comment thread lib/driver.rb
Comment on lines +19 to +21
unless super(id) > 0
raise ArgumentError
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm pretty sure super doesn't do what you think it does. For initialize doesn't return a value it just initializes the CsvRecord and raises an ArgumentError if there's a bad id so checking here is unnecessary.

Suggested change
unless super(id) > 0
raise ArgumentError
end

Comment thread lib/driver.rb
@vin = vin

unless vin.length == 17
raise ArgumentError

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Including a message that contains the bad argument is helpful for debugging and your users.

Suggested change
raise ArgumentError
raise ArgumentError, "Bad vin: #{vin}"

Comment thread lib/trip.rb

module RideShare
class Trip < CsvRecord
attr_reader :id, :passenger, :passenger_id, :start_time, :end_time, :cost, :rating

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not clear on why you removed :id from this list.

Comment thread lib/trip.rb
Comment on lines +33 to +37
unless passenger_id == nil
if passenger_id < 1
raise ArgumentError
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can be simplified as:

Suggested change
unless passenger_id == nil
if passenger_id < 1
raise ArgumentError
end
end
raise ArgumentError, "Bad passenger_id: #{passenger_id}" unless passenger_id.nil? || passenger_id >= 1

Comment thread lib/trip_dispatcher.rb
def available_drivers
available_drivers_list = []
@drivers.each do |driver|
if driver.status == :AVAILABLE && (driver.trips.each { |trip| trip.end_time != nil })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You almost certainly want all? here not each. (each always returns the original array, all? returns a boolean.)

Suggested change
if driver.status == :AVAILABLE && (driver.trips.each { |trip| trip.end_time != nil })
if driver.status == :AVAILABLE && (driver.trips.all? { |trip| trip.end_time != nil })

Comment thread lib/trip_dispatcher.rb
best_driver = nil
available_drivers_list.each do |driver|
# Pick first driver in array of available drivers that has nil or no trips
if driver.trips == nil || driver.trips == []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can be made a little clearer with:

Suggested change
if driver.trips == nil || driver.trips == []
if driver.trips.nil? || driver.trips.empty?

Comment thread test/driver_test.rb
driver2.add_trip(trip)
driver2.add_trip(trip2)

expect(driver2.total_revenue).must_equal ((43 + 56) - (1.65 * 2)) * 0.8

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should use must_be_close_to when comparing Floats because they are imprecise.

Comment on lines +196 to +202
@dispatcher2.available_drivers.each do |driver|
if driver.status == :UNAVAILABLE
return false
else
return true
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This method doesn't actually check all statuses. It only checks the first status since it returns on the first time through the each loop.

You probably wanted to use .all? instead of .each:

Suggested change
@dispatcher2.available_drivers.each do |driver|
if driver.status == :UNAVAILABLE
return false
else
return true
end
end
@dispatcher2.available_drivers.all? do
driver.status != :UNAVAILABLE
end

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