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

Jimmy Lyons take-away challenge #2233

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

jimmy-lyons
Copy link

@jimmy-lyons jimmy-lyons commented May 3, 2022

Jimmy Lyons

User stories

Please list which user stories you've implemented (delete the ones that don't apply).

  • User story 1: "I would like to see a list of dishes with prices"
  • User story 2: "I would like to be able to select some number of several available dishes"
  • User story 3: "I would like to check that the total I have been given matches the sum of the various dishes in my order"
  • User story 4: "I would like to receive a text such as "Thank you! Your order was placed and will be delivered before 18:52" after I have ordered"

README checklist

Does your README contains instructions for

  • how to install,
  • how to run,
  • and how to test your code?

@@ -0,0 +1,80 @@
## Takeaway Weekdend Challenge

Choose a reason for hiding this comment

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

Good glaven this is a comprehensive and highly helpful README

end

def see_restaurant_menu(restaurant)
@currently_viewed_menu = Menu.new(restaurant)

Choose a reason for hiding this comment

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

This is a nice bit of abstraction (think that's the word) - didn't occur to me at all

end

def csv_to_hash
@file.readlines.each do |line|

Choose a reason for hiding this comment

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

Wish I could comment intelligently on how you've handled this with a .csv file, but it's way beyond my understanding

@current_order.push({item => @menu.menu_hash[item]})
end

def remove(item)

Choose a reason for hiding this comment

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

This feels a little complicated for one method,, but I'm sure there are good reasons for that

Choose a reason for hiding this comment

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

Could you use encapsulation to move some of these long operations into a private method and make the main body of the code more readable?

if current_order.empty?
@printed_order
else
format_order

Choose a reason for hiding this comment

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

Nice SRP

def order_total
@total = 0
calculate_total
return "£#{'%.2f' % @total}"

Choose a reason for hiding this comment

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

Oo, nice rounding

require 'twilio-ruby'

class Text
def initialize(number, acc_sid, a_token)

Choose a reason for hiding this comment

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

Not sure I understand the thinking here, particularly with the method commented out in order.rb. Would be good to chat it through

Copy link

@SamButton12 SamButton12 left a comment

Choose a reason for hiding this comment

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

Hi Jimmy, Lovely work on this challenge. I especially like that you've really gone beyond the user stories to add CSV files, use different types of restaurants and added a homepage.

expect(subject.display_restaurants).to be_an_instance_of(String)
end

# it 'should list restaurants with corresponding csv files' do

Choose a reason for hiding this comment

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

I think that best practice is to delete redundant code and comments before pull requesting. (nit-picking)

expect(order.current_order.length).to eq 1
end

it 'should only add items from the initialised menu' do

Choose a reason for hiding this comment

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

You could make this slightly more readable. You already have the #add describe block, so probably dont need the 'add' in the it block (nit-picking)

end

def see_restaurant_menu(restaurant)
@currently_viewed_menu = Menu.new(restaurant)

Choose a reason for hiding this comment

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

Would initializing a new menu and order help here?

@current_order.push({item => @menu.menu_hash[item]})
end

def remove(item)

Choose a reason for hiding this comment

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

Could you use encapsulation to move some of these long operations into a private method and make the main body of the code more readable?

Copy link

@eoinmakers eoinmakers left a comment

Choose a reason for hiding this comment

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

Good implementation of the Takeaway challenge, well done. You've clearly demonstrated the objectives of the week.

There's a good range of unit tests here, but in some cases all you need to do is verify that other methods have been called. https://stackoverflow.com/questions/21262309/rspec-how-to-test-if-a-method-was-called For example, where a method is responsible for calling a private method, or a method of another class.

@order = nil
end

def display_restaurants

Choose a reason for hiding this comment

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

This feels like an addition to the project specs, which you should be careful about - trying to adhere as closely to the spec as possible is always a priority for projects & tech tests.

# Can't figure out how to put csv files in a separate folder.
# It always seems to return an error.

class Menu

Choose a reason for hiding this comment

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

In this project, something as simple as a Hash or array of Dish objects is fine to represent the menu.

array_item = {item => @menu.menu_hash[item]}
fail "Input error: Item not in current order." unless @current_order.include? array_item
i = current_order.find_index(array_item)
@current_order.delete_at(i)

Choose a reason for hiding this comment

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

Deleting an item from the order is also an additional feature! It's definitely functional, but adds unnecessary complexity to your development and end result.

# def confirm_order(number, acc_sid, a_token)
# # method required to send order to restaurant
# sms = Text.new(number, acc_sid, a_token)
# end

Choose a reason for hiding this comment

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

We try to remove commented out code / test snippets before opening PRs for tidiness.

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.

4 participants