Skip to content

Conversation

@katemyer
Copy link

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? The superclass structure and methods have already been given/written, so we could create subclass(es) and overwrite methods for subclasses as needed. The existing tripdipacther.rb file was very helpful that provided the ability to find driver, passenger, and connect drivers and passengers to the trips.
What inheritance relations exist between classes? CsvRecord is a superclass/parent class of Trip, Passenger, and Driver subclasses. CsvRecord is a parent class that provides the child classes the ability to access/read the csv files. However, the subclasses have their own overwritten class method self.from_csv(record) that is carried from the parent class's method. In addition, the sub classes also have other class methods and instance methods that can be used for that subclasses. In short, the subclasses have everything from their parent class (CsvRecord) plus additional methods as needed. The TripDispatcher class is a class that drives all the connections between trips, drivers, and passengers.
What composition relations exist between classes? Regarding Composition - relations, the trip cannot exist independently without the driver and passenger - the trip is composed by driver and passenger. In order to make a trip instance, we have to have a driver and a passenger. In this problem, each trip links to only passenger, but in reality, the a trip can link to many passengers that those passengers can be stored in an array of passengers.
Describe a 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 decide on whether we were looking at a variable or a constructor within a variable and then how to denote that to keep it clear for our understanding when tackling the next day's goals. Furthermore, we had to agree on what object we were actually examining when it came to writing our tests. We were able to communicate and talk out (thanks to Lak) our logic when we got confused at any point in the project. Our decisions were made based on what we were asked to do for each Wave and the given tests. The given/existing tests allowed us know what the expectations were. By looking at the given structure and the instruction of the project, we knew that the Trip, Driver, and Passenger were the subclasses of the super class CsvReader, but we first were not clear how to make connections among those subclasses. In Wave 1 and Wave 2, we knew that each driver could have multiple trips and each passenger also could have multiple trips, so we had to make the decision how we wanted to store the information of all the trips for each driver and passenger. We decided to store all the trips for each driver in an array, and we did the same thing to the passenger. By storing the trips in an array, it would be easier for us to access/retrieve the information of the trip such as cost, rating, duration, and so on. When a driver had a trip, the trip would get added to the @trips array of the driver instance. Similarly, if passenger had a trip, the trip would get added into the @trips array of the passenger. Wave 3 made more sense to us when we were asked to create a request_trip method in the trip_dispatcher.rb - the trip instance is created only when there is a passenger and a driver. When the trip is created, the trip instance will be added into passenger's @trips instance variable and driver's @trips instance variable.
Give an example of a template method that you implemented for this assignment self.from_csv(record) in CsvRecord class is abstract/template method. There are three subclasses (Trip, Driver, and Passenger). Each subclass overwrote the template method self.from_csv(record) based on its needs. For example, we wrote Drive.from_csv(record) for the Drive class.
Give an example of a nominal test that you wrote for this assignment Example of a nominal test: we devised bad data and expected a failure. We tested the VIN number for the driver. The VIN is String of length 17. We expected to Raise an ArgumentError when we gave an invalid string.length value of VIN = "33133313331333133extranums"
Give an example of an edge case test that you wrote for this assignment Edge case test: input the value that is close to the rank of working values. We tested total_time_spent for the driver. We devised three trips for the driver, but one of the trips didn't have the end_time(end_time = nil). We expected to see only two end_times that were added to get the total_time_spent.
What is a concept that you gained more clarity on as you worked on this assignment The concept of writing methods along side tests became clearer. We saw the efficiency in moving simultaneously.

@kaidamasaki
Copy link

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
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 ✔️
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)
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

Copy link

@kaidamasaki kaidamasaki left a comment

Choose a reason for hiding this comment

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

Good job! Here are a few small things you can do to clean up your code and make it more concise.

Comment on lines +1 to +14
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Local File",
"type": "Ruby",
"request": "launch",
"program": "${file}"
}
]
} No newline at end of file

Choose a reason for hiding this comment

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

You should probably globally ignore your .vscode folder.

https://help.github.com/en/github/using-git/ignoring-files

source 'http://rubygems.org'

ruby '2.5.5'
ruby '2.7.0'

Choose a reason for hiding this comment

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

We're using Ruby 2.6.5 for this current cohort:

Suggested change
ruby '2.7.0'
ruby '2.7.0'

Comment on lines +11 to +17
def initialize(
id:,
name:,
vin:,
status: :AVAILABLE,
trips: nil
)

Choose a reason for hiding this comment

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

If you indent your argument list it makes it easier to distinguish from the method body.

Suggested change
def initialize(
id:,
name:,
vin:,
status: :AVAILABLE,
trips: nil
)
def initialize(
id:,
name:,
vin:,
status: :AVAILABLE,
trips: nil
)


#Raise argument for vin
if @vin.length != 17
raise ArgumentError.new("Invalid VIN number, needs to be 17 in length.")

Choose a reason for hiding this comment

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

It's helpful to include the bad argument in the message for your ArgumentError:

Suggested change
raise ArgumentError.new("Invalid VIN number, needs to be 17 in length.")
raise ArgumentError.new("Invalid VIN number: #{@vin}, needs to be 17 in length.")

#Wave 2: Adding trips to the driver
def add_trip(trip)
@trips << trip
#self.trip << trip

Choose a reason for hiding this comment

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

It's considered best practice to remove commented out code:

Suggested change
#self.trip << trip

end

#Wave 3: Find driver_by_status
def find_driver_status(status)

Choose a reason for hiding this comment

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

The name find_driver_status is misleading since it sounds like you are looking for the status of a single driver.

Suggested change
def find_driver_status(status)
def find_driver_by_status(status)

#Wave 3: request_trip method
#Wave 3: added new instance of trip
def request_trip(passenger_id)
available_driver = @drivers.select {|driver| driver.status == :AVAILABLE}.first

Choose a reason for hiding this comment

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

Using find here is a little clearer (since it's easy to miss the .first at the end of the line):

Suggested change
available_driver = @drivers.select {|driver| driver.status == :AVAILABLE}.first
available_driver = @drivers.find {|driver| driver.status == :AVAILABLE}

Comment on lines +58 to +59
@trip_data[:start_time] = Time.parse("2018-12-27 02:00:00 -0800")
@trip_data[:end_time] = Time.parse("2018-12-27 01:00:00 -0800")

Choose a reason for hiding this comment

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

In your tests I'd recommend directly constructing objects instead of parsing strings. Also, when using a Time or Date there are some helpful factory methods: Time.now and Date.today.

Suggested change
@trip_data[:start_time] = Time.parse("2018-12-27 02:00:00 -0800")
@trip_data[:end_time] = Time.parse("2018-12-27 01:00:00 -0800")
@trip_data[:start_time] = Time.new(2018, 12, 27, 2)
@trip_data[:end_time] = Time.new(2018, 12, 27, 1)

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.

2 participants