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

Update worksheet.rb #46

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

Update worksheet.rb #46

wants to merge 1 commit into from

Conversation

kashenafi
Copy link

@kashenafi kashenafi commented Sep 14, 2020

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 made an hash with the driver info as key and the value a nested array of (the info of) each ride that driver gave. The structure didn't evolve though I was successful in assigning it to a new variable and re-arranging it to do the optional portion, it got a little too complicated and disproportionately time consuming, so I had to settle for the required data computations.
What was your strategy for going through the data structure and gathering information? I created an hash with the driver IDs as symbols and the corresponding ride infos as a nested array. I then sorted the symbol keys to appear in order (driver 1 first). In each method I analyzed the hash and (like a pattern) pushed the relevant information/answer into an array (which is what the methods return).
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? It was necessary to select the desired data to be stored into a small array (per driver, or ride) and then have that info systemically (pattern) pushed into a bigger array, iterating over that array to select, compute and return the appropriate result.
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 .map in several instances. For example, I used it when computing the total earned by each driver, it returned an array of the drivers individual earnings, I passed it to sum(), and pushed the return into an array to be stored for reference. It was convenience was I need to create a new array with the desired values and have it assigned to a variable within each method so I can easily reference the values (especially convenient when doing other calculations to or with that variable (that array of selected elements).
Were some calculations easier than others? Why? The calculations that required simple calculation THEN comparison where harder (even harder is when calculation is more challenging, i.e. the optional). This was because my strategy included a system of storing each amount that needs comparison into small arrays, from which the appropriate value would be selected, to be nested in a bigger array (holding qualifying answers) for outputting. All this requires a lot of logic. Some calculations where easier because I was able to notice and follow patterns.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

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 It looks like you added a drive for Driver 4, but given this, all your calculations are correct!
... 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

Great work on this assignment. You worked through some tricky logic and clever ways, and practiced using enumerable methods.

It can be hard to find a balance between encapsulating functionality in individual methods, and using a single method to perform multiple calculations. We will keep practicing this and seeing examples.

Great work on formatting your output in a way that is very readable. Keep up the hard work!

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
Elegant/Clever

# - Which driver has the highest average rating?

ride_log = { DR0004: [["3rd Feb 2016",5,"RD0022",5],

Choose a reason for hiding this comment

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

Consider storing each individual trip as a hash rather than an array. For example

{date: "3rd Feb 2016", cost: 5, rider: "RD0022", rating: 5}

This will increase readability and make it so you don't need to rely on knowing which column the data is stored in, but can use the keys to index the values you need.

end

def rides_each_driver(log)

Choose a reason for hiding this comment

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

Great work breaking up the functionality into different methods and giving each method a meaningful name. Consider also giving all variables meaningful names to increase readability. Consider what you're storing in big_array and what would be an appropriate name.

Comment on lines +158 to +159
puts total_each_driver(ride_log)

Choose a reason for hiding this comment

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

Since these two methods both calculate totals for drivers, it might simplify and speed up your code to combine this functionality into a single 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.

2 participants