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

Sigrid & Barbara, Edges, oo-ride-share #7

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

Conversation

BarbaraWidjono
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? We needed to make a design decision as to how an 'InProgress' trip was to be handled by the constructor and subsequent calculations. Two options considered: changing the falsey nil into a string "nil"--the other option was changing the falsey nil into a string "InProgress." It was decided to convert falsey nil into string "InProgress" to prevent any confusion in testing between falsey nil and string "nil."
Describe any examples of composition that you encountered in this project, if any Yes, a single TripDispatcher object can have multiple Users, Drivers and Trips. A single Driver can have many Trips. A single User can have many Trips.
Describe the relationship between User and Driver The class User is the superclass to the subclass Driver.
Describe a nominal test that you wrote for this assignment. Within the 'request_a_trip' test, we checked for the instantiation of a Trip instance and checked that the new instance was added to the user, driver and all trips.
Describe an edge case test that you wrote for this assignment Within the 'request_a_trip' test, we checked that a trip could not be requested if the user_id was invalid (was not a User object).
Describe a concept that you/your pair gained more clarity on as you worked on this assignment Gained clarity on how a variable points to a memory location which stores a value. A little bit more clarity (for Barb) regarding Minitests and the use of 'before-do' blocks.
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? I appreciated Sigrid's attention to detail and her ability to write and explain testing. I (Sigrid) appreciated Barb's checking in with me on how I felt about the division of work, and her willingness to work both individually and collaboratively.

sdbenezra and others added 28 commits August 27, 2018 15:48
… check in Trip#initialize to check for end time prior to start time.
…t. Also corrected driver.add_driven_trip and passenger_as_driver.add_trip lines in load_trips method.
…n method in trip.rb file to handle @end_time value of In Progress.
@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 yes
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 yes - missing some edge cases, 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, good work
Methods from wave 1 and 2 handle incomplete trips yes - good work
Tests for wave 1 and 2 methods with incomplete trips yes
Overall Great job overall! This submission is quite strong. There are a few places where things could be cleaned up or test coverage expanded, which I've tried to call out inline below, but in general I'm happy with what I see. Keep up the hard work!

if @end_time == nil
@end_time = "In Progress"
elsif @end_time < @start_time
raise ArgumentError, "End time is before start time"

Choose a reason for hiding this comment

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

I would much rather have nil than a string to indicate a trip is in progress.

it "Does not include trips in progress in calculation of total amount spent on trips" do

run_trip_dispatcher = RideShare::TripDispatcher.new()
trip2 = RideShare::Trip.new(id: 9, driver: nil, passenger: @user,

Choose a reason for hiding this comment

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

Good work getting this edge case. Another one to consider: what if the user has not yet taken a trip?

def net_expenditures
net_expenditures = super
difference = net_expenditures - total_revenue
# difference = super - total_revenue # can use super in place of above code.

Choose a reason for hiding this comment

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

Good use of super here.

@driven_trips.each do |x|
# binding.pry
if x.rating == "In Progress"
next

Choose a reason for hiding this comment

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

You tended to use .each iteration to calculate totals/sum things in Driver and User, even though things like .sum is available. Honestly, I don't believe that you ALWAYS need to use fancy Enumerable methods like .sum over .each iteration every time, but I want to make sure you know that those are possibilities.

it 'checks if driver.net_expenditures overrides user.net_expenditures' do
difference = @driver.net_expenditures
expect(difference).must_equal 10 - ((4 - 1.65) * 0.80)
end

Choose a reason for hiding this comment

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

This is a good start, but I believe there are some more interesting cases here. For example, what if a driver has:

  • No driven trips
  • No trips as a passenger
  • An incomplete trip as a driver or passenger
  • Made more money than they've spent


else
return "No available drivers"
# return nil

Choose a reason for hiding this comment

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

You should either return nil or raise an exception here, not return a string. There are a number of reasons for this, but ultimately what it comes down to is, in order to check that a string contains an error message, you need to read it.

# Checking for available drivers that do not have the same id as the user requesting a ride
available_drivers = []
@drivers.each do |x|
if x.status == :AVAILABLE && x.id != user_id.to_i

Choose a reason for hiding this comment

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

This would be a great piece of logic to move to a helper method.

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