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

First pull request #646

Closed
wants to merge 16 commits into from
Closed

First pull request #646

wants to merge 16 commits into from

Conversation

rossbenzie
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling e25234f on rossbenzie:master into ** on makersacademy:master**.

Copy link
Contributor

@neoeno neoeno left a comment

Choose a reason for hiding this comment

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

Hi Ross!

I like the class structure for the most part — straightforward but still pretty well separated. I think Order might be doing too much though — try writing an "Understands..." comment for it. Think about where you're delegating to Basket too — which bits of the methods should be in Order and which in Basket, and why.

The methods are small and concise, which is great, but sometimes border on low readability: e.g. if I'm using Order and I don't want to worry about reading it, what do Order#add and Order#cancel do? I guess Order#cancel probably cancels the order, but then does Order#add add an order? Turns out it doesn't. We could figure it out but it'd be nicer if we could tell at a glance what the method does.

The use of private methods to make the public methods more readable is super good 👍

Some of the tests do a good job of testing (Basket), some of the others do a less good job. respond_to is good for the first stages of TDD, but if that ends up being your only test on a method then I'd suggest thinking about whether your tests are doing the job they should be. Try breaking a bit of the method and seeing whether your tests fail.

Nice work here!

"Thank you. Your order was placed and will be delivered before"
end
def delivery_time
"#{(Time.now.hour + 1).modulo(24)}:#{Time.now.min}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice — good catch on the modulo thing. This would have been a good opportunity to test #buy to make sure it behaves well at 11pm, midnight, 1am etc — and thereby a good opportunity to use mocking to ensure you didn't have to stay up until midnight just to run your tests.

end
def display_basket
basket.each_item do |item, qty|
printf("%-20s %5d %8.2f \n", item, qty, menu.price(item))
Copy link
Contributor

Choose a reason for hiding this comment

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

I've not seen printf used a lot in ruby — but I think this is a neat piece of code. I'd personally spend quite a while trying to figure out how to make it more readable, though. How could I make it clearer what's going on here?

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 6e4ba82 on rossbenzie:master into ** on makersacademy:master**.

@sjmog sjmog closed this Dec 4, 2017
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.

None yet

4 participants