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

Pipes - Kimberley Zell - Hotel #22

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

Conversation

kimpossible1
Copy link

Hotel

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Describe a design decision you had to make when working on this project. What options were you considering? What helped you make your final decision? When making Blocks I had to decide if I wanted to make a separate class for Block Admin or handle it under the same Admin area as the regular Bookings. I also had to decide if I wanted to make a separate class for Block Bookings. I went with making a class for the Block itself, and then using my Booking class when making a block booking. I kept the admin part with my Reservations class. The functionality of each part of the Block helped me decide where to put it.
Describe a concept that you gained more clarity on as you worked on this assignment. I think I better understand what initialize does and what can be put in initialize. I also better understand what the attr reader vs accessor does. I had started using most att_reader from what we talked about in class, that it's important to not let things be write accessible if there isn't need for it, but I did not realize that would mean I also cannot access things that are not writeable in other parts of my code. So after I understood that better, I started using attr_accessor more. Overall I feel that I'm getting better with using classes and definitions.
Describe a nominal test that you wrote for this assignment. I wrote a test to make sure my program won't allow a room booking to go through if the room is already booked.
Describe an edge case test that you wrote for this assignment. I wrote a test to make sure that my program won't allow a booking on a room block if the room is not reserved for the block.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I think I did okay. I tend to sometimes write some code in with my pseudocode. I'm pretty sure my code could be refactored to be more concise, and there must be a better way to organize. The Reservations class became particularly long. I perhaps could make more classes.

… collection of rooms. Began creating tests for Booking class and created file for Booking class.
…hod to create a new reserveration under Reservations class. Need to make tests for new_reservation method
…a reservation, so that can generate list of reservations on a specific day. Added method under Reservations for list reservations by day but it is not complete yet.
… dates included in the reservation in string format - was not able to figure out how to get it to dates format directly just yet
…do not pass. Received feedback from Dan that I sould not be mixing self methods/variables and instance methods/variables. Next will adjust code to have all instance methods/variables (in Reservations class).
…ions by date method. Still does not work - not able to call method dates within the reservations class.
… this resolved the issues with Reservations method list reservations by date.
…ray. Fixed Reservations list reservations by date method. Dates must be coming through in slightly different format. Found work around to verify if dates in reservation match with date passed in.
…alidate dates. Added that method to initialize for Booking. Wrote tests for check if invalid dates raise Invalid DateError. Tests are not passing and I'm not sure why.
…tion and method to auto-assign room number if a room not chosen when creating a new reservation. Not running correctly yet. Will write tests to try to debug
…thod. Appears auto assign room number may be working without the available method. Available method appears not to be working. Temporarily commented out most of available method so that it only returns true. Will write tests for auto assign room number and then further troubleshoot available method.
… is not available when a new reservation is being made. Started creating method to list all rooms available by date and testing. It is not passing tests yet.
…blocks called @blocks. New Blocks get added to the collection when created. Wrote tests as well.
…oms. Room collection for the block is created based on number of rooms needed and available rooms for those dates. Started a method to list blocks by dates. Goal is to add this to the availability checks so that rooms will not show as available for general bookings.
…to revamp or update the available method so that it prevents rooms from being booked if they are on the available list
…w failing. New method includes checking for rooms in blocks. Need to find out why older tests for new reservations are failing. Then need to test if it works correctly with blocks.
…k and list be available date to accomodate blocks appropriately. Added new variable to indicate whether a new reservation is for a block as well. Need to write tests and also incorporate the new methods in the new reservations and new block reservations to see if they work.
…es within Block class to store info on rooms that have been booked. Added test in Block spec to test. This is working. Also have been drafting some methods within reservations that need to be tested and arranged.
…o not think I will need this. Created tests for list blocked rooms by date method within Reservations class. Corrected the method so that it functions properly. Going through all methods in Reservations to create tests and be sure each one is working properly. Check availability by date is not working properly since I rewrote the method adding in to account for blocks, so I am looking at all methods involved to trouble shoot. Currently it does not raise arugment error when a room is not available as it should.
…ted to include room numbers to prevent accidental fails. Something wrong with Atom. Pushing now in hopes that work will not be lost.
…in the new_reservation method under Reservations Class. Otherwise it was checking the room_number of the previous reservation instead of the current one.
…n block started. Tests also started. Writing more tests and then adding more functionality.
…the room requested for booking is actually in that block, and gives an error message if it is not.
…tests - not raising argument error. Have not been able to find the problem yet.
…block reservations match the block date range.
…ation is for. Fixed method and tests for checking if a room inputed during a new block reservation is in the block, which prevents booking if the room is not part of the block. All methods currently passing tests. Just need to clean up a bit.
@droberts-sea
Copy link

Hotel

What We're Looking For

Feature Feedback
Baseline
Used git regularly yes - good work
Answer comprehension questions yes
Design
Each class is responsible for a single piece of the program some - see my inline comments about DateRange
Classes are loosely coupled mostly - I noticed a couple places where classes are hard to separate, but in general this looks good.
Wave 1
List rooms yes
Reserve a room for a given date range yes
List reservations for a given date yes
Calculate reservation price yes
Invalid date range produces an error yes
Test coverage missing some cases around listing reservations and available rooms - see inline
Wave 2
View available rooms for a given date range yes
Reserving a room that is not available produces an error yes
Test coverage missing many interesting cases around availability checking - see inline
Wave 3
Create a block of rooms yes
Check if a block has rooms yes
Reserve a room from a block yes
Test coverage missing some
Additional Feedback
File Names The ruby standard is that files should be named using snake_case - all lowercase, underscores between words. So instead of lib/DateRange.rb it would be lib/date_range.rb. Same for spec files, so the corresponding spec would be specs/date_range_spec.rb.
General Vibe This is a good start, but it feels like there's a way to go still. The general pattern I notice is that your specific code within a method is usually solid, but design and test coverage could be improved. To me, this indicates you're having trouble taking a step back and imagining what your code looks like from the outside, thinking about what pieces ought to go where or what could go wrong. This important skill is difficult to master, but it's one you can grow with deliberate practice.


def all_rooms
@rooms_collection = []
n = 1

Choose a reason for hiding this comment

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

This method will recreate all the rooms from scratch every time it's called. This is a problem because any reference to a room from before won't register as equal to a room from after even if they have the same room number, because the object IDs will be different.

A better strategy might be to check if the list already exists at the beginning of this method, and if it does immediately return it.

def new_reservation(check_in, check_out, room_number = rand(1..20), room_rate = 200)
dates = Hotel::DateRange.new(check_in, check_out).dates
booking = Hotel::Booking.new(check_in, check_out, room_number, room_rate)
if check_availability?(dates, room_number) == false

Choose a reason for hiding this comment

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

All the places that you create a DateRange, it seems like you're only using it as a tool to get an array of dates. This indicates that a method might be a better choice here, one that takes a checkin and checkout date and returns an array of dates.

The other option would be to write an instance method, something like DateRange#overlap?(other), that takes another DateRange and checks to see if they overlap. Then this complex bit of logic would be hidden away in DateRange instead of sitting here in Reservations.

As long as you've identified "manage a range of dates" as a responsibility, then it probably makes sense to do the later, and keep that responsibility out of the Reservations class.

This would also make it much easier to test!

lib/Booking.rb Outdated

def total_cost
num_days = (@check_out - @check_in).to_i
total_cost = @room_rate * num_days

Choose a reason for hiding this comment

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

Since you have this method defined here, you should not have an attr_accessor for :total_cost above (since this method will override the generated one).

lib/Booking.rb Outdated
@check_in = Date.parse(check_in)
@check_out = Date.parse(check_out)
@date_range = DateRange.new(@check_in, @check_out)
@dates = @date_range.dates

Choose a reason for hiding this comment

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

Instead of storing the check_in, check_out and dates here, it might be cleaner to only store the DateRange instance, and anyone who needs those attributes for a booking will have to go through date_range. That makes for a very clean separation of responsibilities: a Booking doesn't need to know what parts a DateRange has or how it works, it just knows that it has one.

lib/Booking.rb Outdated
validate_dates
end

def validate_dates

Choose a reason for hiding this comment

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

I like that you run this validation right in the constructor, and that you've broken it out into a separate method. It might make even more sense as a check on the DateRange class, rather than having a Booking be responsible for this.

# end
it 'must must raise argument error if room is not available' do
proc{ new_reservation2 = @new_hotel.new_reservation("2018-01-01", "2018-01-04", 1) }.must_raise ArgumentError
end

Choose a reason for hiding this comment

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

This is a good start, but I'd like to see more coverage around what date ranges will conflict with each other. Cases I'd be interested in:

  • Not available:
    • Same dates
    • Overlaps in the front
    • Overlaps in the back
    • Completely contained
    • Completely containing
  • Available:
    • Completely before
    • Completely after
    • Ends on the checkin date
    • Starts on the checkout date

end
it 'must return the correct rooms available' do
@new_hotel.list_rooms_available_by_date("2018-01-03")[0].room_number.must_equal 3
end

Choose a reason for hiding this comment

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

Other cases I'd be interested in:

  • What if there are no reservations? (it should return a list of all the rooms)
  • Do reservations that don't overlap the date range affect the list? (they shouldn't)
    • Check the boundaries of what counts as an overlap. What about a reservation that ends on the checkin date, or starts on the checkout date?
  • What if there are no vacancies? (it should return an empty array)
  • What if your date range spans several small reservations? (all of the rooms from those reservations should be omitted from the list)

end
it "must return the correct reservations" do
@new_hotel.list_reservations_by_date("2017-09-21")[0].room_number.must_equal @new_booking1.room_number
end

Choose a reason for hiding this comment

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

You're missing some test cases here - they look very similar to the ones I would like to see for listing rooms by date.

it 'must return false if there are NOT any rooms available in block to be booked' do
@new_block_reservation3 = @new_hotel_with_blocks1.new_reservation_in_block("2018-01-01", "2018-01-05", "Heritage", 8)
@new_block_reservation4 = @new_hotel_with_blocks1.new_reservation_in_block("2018-01-01", "2018-01-05", "Heritage", 9)
@new_block_reservation5 = @new_hotel_with_blocks1.new_reservation_in_block("2018-01-01", "2018-01-05", "Heritage", 5)

Choose a reason for hiding this comment

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

Good failure case!

end
it 'must list the correct number of rooms for a given date' do
@new_hotel.list_blocked_rooms_by_date("2018-01-02").length.must_equal 5
end

Choose a reason for hiding this comment

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

Similar missing cases as for Booking above.

…es in the spec_helper file and have restarted both Atom and terminal but it's still not working. Wrote additional tests under reservations_specs.
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