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

Branches - Diana Han #36

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

Branches - Diana Han #36

wants to merge 4 commits into from

Conversation

dhan0406
Copy link

@dhan0406 dhan0406 commented Aug 26, 2019

Grocery Store

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Response
What is accomplished with raise ArgumentError? By raising ArgumentError, we're able to check if the tests passed by passing in "bogus statements" in our code to see that it will result in an error.
Why do you think we made the .all & .find methods class methods? Why not instance methods? We wanted to create methods that can operate on the class members and read in from the data in the csv files.
Think about the relation between Order and Customer. Is this relation one-to-one, one-to-many, or something else? How does that compare to the Solar System project? The relationship between Customer -> Order can be defined as one-to-many. One customer can have multiple different orders in this case. The Solar System is similar in the way that in one solar system -> there can be many planets.
How is the relation between Order and Customer tracked in the CSV file? How is it tracked in your program? Why might these be different? The order csv and customer csv files were linked by customer ids. I needed to require Customer class in the Order class file in order to find the customer info that correlates to the customer id provided in the orders.csv.
Did the presence of automated tests change the way you thought about the problem? How? Yes, without using a CLI to test if my code is working, I had to rely on the tests to verify that my code was working properly. The tests provided a guide as to what I needed to do to ensure that my code was properly reading in data from the csv files.

def self.find(id)
customers = self.all

result = customers.select {|customer| customer.id == id}

Choose a reason for hiding this comment

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

You might want to look at Enumerable#find to simplify this a little.

attr_reader :id
attr_accessor :products, :customer, :fulfillment_status

STATUS = [:pending, :paid, :processing, :shipped, :complete]

Choose a reason for hiding this comment

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

Style: collections should have plural names.

Suggested change
STATUS = [:pending, :paid, :processing, :shipped, :complete]
STATUSES = [:pending, :paid, :processing, :shipped, :complete]

if STATUS.include?(fulfillment_status)
@fulfillment_status = fulfillment_status
else
raise ArgumentError

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 a message with the bad status:

Suggested change
raise ArgumentError
raise ArgumentError.new("Bad fulfillment status: #{fulfillment_status}")

@kaidamasaki
Copy link

Well done! There were a few little things I pointed out but other than that everything looked good!

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