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

Space - Faezeh #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

faezeh-ashtiani
Copy link

Assignment Submission: Ride Share

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

Reflection

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? I thought of 4 methods of layering the data, I ultimately I chose method 3 as it proved to be better for answering the questions in this exercise. 1- the entire rides (hash )>> the drivers (hash) >> dates (hash) >> each ride (key value pairs) -- number 1 was only using hashes and was making accessing the necessary data more difficult. 2- the entire rides (hash) >> dates (hash) >> drivers (hash) >> each ride (key value pairs) -- like number 1, this was one also only using hashes and was making accessing the necessary data more difficult. 3 - the entire rides (hash) >> drivers (array )>> each ride (key value pairs of the rest of information)4 - the entire rides (hash) for which the keys would be each column of the given table and the values would be for example and array of all the driver's IDs in the same order as the table. -- this layer nesting was very hard to read and confusing
What was your strategy for going through the data structure and gathering information? I defined 3 variables for number of rides, total income and average rating of each driver before going into the report section, since these informations were used in multiple report questions.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I initially defined 3 variables for number of rides, total income and average rating of each driver. The data type of these variables were hashes and the keys for the pairs were the driver IDs. This organization of data resulted in easier retrieval and less repetition of code in reporting the results.
What kinds of iteration did you use? Did you use .map? If so, when? If not, why, or when would be a good opportunity to use it? I used .each iteration multiple times throughout the program to iterate over each driver's information key - value pair in the all_rides hash. I used .map 3 times, and all in places where I wanted to output an array of the same size with the array of information of each ride (the lowest level of data)
Were some calculations easier than others? Why? calculating number of rides each driver had performed was easier since it involved higher level of information from the data structure (in other words, I did not need to dig deep to get the information)

@dHelmgren
Copy link

Ride Share

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly creates, reads, and modifies variables ✔️
Correctly creates and accesses arrays ✔️
Correctly creates and accesses hashes ✔️
Reasonably organizes large amounts of related data into nested arrays and hashes ✔️
Correctly iterates through a nested data structure using loops and/or Enumerable methods ✔️
Reasonably organizes small pieces of code into methods, and calls/invokes those methods

Functional Requirements

Functional Requirement yes/no
To the terminal, the program outputs the correct number of rides each driver has given ✔️
... outputs the total amount of money each driver has made ✔️
... outputs the average rating for each driver ✔️
... outputs which driver made the most money ✔️
... outputs which driver has the highest average rating ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 4+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 2-3 in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0,1 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
Descriptive/Readable


# based on layering (nesting) method 3:
all_rides = {
:DR0001 => [

Choose a reason for hiding this comment

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

Don't forget, when you use symbols as a hash key, you can write lines like this as DR0001: [

Comment on lines +38 to +57
rides_num = {}
all_rides.each do |driver, rides|
rides_num[driver] = rides.length
end

driver_total_income = {}
all_rides.each do |driver, rides|
driver_income = rides.map do |each_ride|
each_ride [:COST]
end
driver_total_income[driver] = driver_income.sum
end

driver_average_rating = {}
all_rides.each do |driver, rides|
driver_rating = rides.map do |each_ride|
each_ride[:RATING].to_f
end
driver_average_rating[driver] = ( driver_rating.sum / rides.length ).round(2)
end

Choose a reason for hiding this comment

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

You iterate over all_rides a lot, with a different goal each time. Is there an opportunity to DRY up this code with a single loop of all_rides and maybe a few methods?

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