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

Melissa_Pushpa_Edges_OO_RideShare #24

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

Conversation

melicious-dish
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 decision that was made is that we spent a lot of time considering the relationships between the classes, and how the info was passed between these classes. We decided that the Trip Dispatcher class was where all the other classes were merging and compiled
Describe any examples of composition that you encountered in this project, if any We had to compose the Driver class and have it be inherited from User Class.
Describe the relationship between User and Driver Driver is a subclass of User and inherits all its attributes
Describe a nominal test that you wrote for this assignment. A nominal test was the driver's total revenue across all their trips. It added sums and calculated the tax and fees. Pretty straight forward.
Describe an edge case test that you wrote for this assignment An edge case test we wrote is for trip_spec. It raises an argument error if the end time entered was before the start time
Describe a concept that you/your pair gained more clarity on as you worked on this assignment Writing tests and doing TTD and how tests and driver code relate. :)
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? Just that we like to give and receive feedback in the person

Melissa O'Hearn and others added 29 commits August 27, 2018 17:01
…ip method as well in driver.rb file, and got tests to pass along with that file.
@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 no
Driver has a method to calculate total revenue yes
Tests for wave 2 no
Wave 3
TripDispatcher has a new method to create trips no
creating a trip in TripDispatcher relies on methods in Driver and User (passenger) to modify their own attributes no
Complex logic was correctly implemented no
Tests for request_trip no
Methods from wave 1 and 2 handle incomplete trips no
Tests for wave 1 and 2 methods with incomplete trips no
Overall

This is a good start. The code that I see so far on this looks solid, particularly product code, and particularly what you've written for wave 1. I also want to acknowledge that this was a difficult project and a rough week in general.

All that being said, I feel there is a lot of room for improvement in this submission.

In my mind, this assignment has 4 core learning goals:

  1. Building an inheritance relationship between two classes
  2. Writing your own tests
  3. Practice with previous concepts, including object composition and complex business logic
  4. Becoming familiar with a large, complex codebase

I would say that each of these was touched upon, but none of them addressed completely:

  1. You used inheritance for Driver, but it looks like you were repeating some of the work in User and weren't able to complete some of the pieces that inheritance helps enable
  2. You wrote tests for wave 1 only
  3. Your product code for waves 1 and 2 is adequate, but much of the interesting logic comes in wave 3
  4. I suspect that the difficulty of getting up to speed on this large codebase is a large part of what prevented you from making more progress

The key thing at this point is to figure out how to make sure these learning goals are met well enough that it won't be an issue once we start Rails. This means the two major points are building complex logic and reading other peoples' code.

You'll have plenty of opportunity for complex logic on the Hotel project. One thing I would recommend is to check in 1-on-1 with an instructor tomorrow (Wednesday), to make sure you're on a good track and making solid progress.

For reading code and understanding a complex codebase, there is an implementation of GroceryStore on the student-soln branch that is worth checking out, and we'll be releasing our official implementation of Hotel once yours is submitted. Being able to quickly read and understand a new library of code is an essential skill for an engineer, so you should take every opportunity to practice.

Again, I want to call out that this project was particularly difficult, and that the code I do see for the most part looks good. Keep your focus and your spirits up, and keep up the hard work!

def net_expenditures
ride_total = 0
@trips.each do |trip|
ride_total += trip[:cost]

Choose a reason for hiding this comment

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

Both these methods will hit an error if you try to run them on a user with an incomplete trip. There are a couple of workarounds for this.

You could explicitly ignore trips with a nil cost:

trips.each do |trip|
  if trip.cost.nil?
    next
  end
  # ... add to the total ...
end

Or even better, you could write a helper method that returns a list of complete trips:

def completed_trips
  return @trips.reject { |t| t.end_time.nil? }
end

def net_expenditures
  completed_trips.each do |trip|
    # ... same logic as before ...
  end
end

Choose a reason for hiding this comment

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

While the above is true, it is less relevant given that you didn't complete wave 3.

# create bunny as an instance of a trip.

bunny = RideShare::Trip.new(trip_data)
# calls the method duration

Choose a reason for hiding this comment

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

Why bunny?

describe "total amount of money user has spent on trips" do
before do
@user = RideShare::User.new(id: 9, name: "Merl Glover III", phone: "1-602-620-2330 x3723",
trips: [{

Choose a reason for hiding this comment

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

I think you're missing some edge cases that are common to both these User methods:

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


if input[:id].nil? || input[:id] <= 0
raise ArgumentError, 'ID cannot be blank or less than zero.'
end

Choose a reason for hiding this comment

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

Doesn't User already check this? If not it probably should.

# binding.pry
# unless @status.include?(status_array)
# raise ArgumentError. "Invalid status, you entered: #{status}"
# end

Choose a reason for hiding this comment

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

Why is this commented out? It does look like line 35 is backward (should be unless status_array.include?(@status).

sum_tax = 1.65
total_rev = 0
@driven_trips.each do |trip|
sum = (trip.cost - sum_tax) * 0.8

Choose a reason for hiding this comment

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

This code would be a little more readable if the two magic numbers (0.8 and 1.65) were stored in constants, maybe something like DRIVER_CUT and FEE.


def net_expenditures
end

Choose a reason for hiding this comment

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

One possible implementation:

def net_expenditures
  return (super - total_revenue).round(2)
end

The key here is taking advantage of code you've already written, both from the parent class using super, and another method in this class.

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