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

Bianca Fernandez <Pipes> Hotel #34

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

Conversation

biciclista22
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? Honestly, just deciding how to divide up the different functionality, what classes would potentially be needed and imagining how they would interact with one another was challenging. I needed to decide if I would create a date range class that would be called in the Reservation class. I was toying with the idea of scrapping it, just allowing it to exist in the reservation class upon initialization, but I also weighed out how important isolated and not super dependent methods and classes are in code's design and ability to change and scale. I also recognize that many parts of my code could have used that decision making as well, breaking up complex chunks of code into simpler snippets.
Describe a concept that you gained more clarity on as you worked on this assignment. Calling a method or an instance method in another class. I also learned more about parent and child class with the Reservation class that I used to make the Block class.
Describe a nominal test that you wrote for this assignment. A go-to nominal test is usually to assert that a certain data structure is what it is meant to be and contains the correct number of items that I expect to be passed into it.
Describe an edge case test that you wrote for this assignment. An edge case certainly came up with the reservation availability method where I needed to make sure that dates did not overlap. I made sure to make a smaller hotel with fewer rooms to choose from and from there, book a couple of those rooms, with some overlapping dates, creating asserts where I knew it should pass and where they should fail. It definitely was helpful in the debugging portion of that logic.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I was able to do it a little, but definitely not as much as I would like or should. I think, personally, some of it has to do with nerves and wanting to see some code on the screen. I learned my lesson though, because, with wave 3, I went right in, hacking away at what I thought could work. I quickly learned a lot of what I wrote would not work because it didn't pass the tests and would need to be rewritten and reorganized. I am thoroughly enjoying the tests as a way to gauge accuracy and even design at times.

…ted a check to make sure check in date came before check out
@droberts-sea
Copy link

Hotel

What We're Looking For

Feature Feedback
Baseline
Used git regularly yes - good work
Answer comprehension questions yes - I'm glad you're enjoying testing!
Design
Each class is responsible for a single piece of the program some - You have a DateRange class, but it doesn't have any instance methods, and all the information you store there is repeated elsewhere. This indicates that you've identified "keeping track of a range of dates" as a responsibility, but haven't isolated that responsibility from your other classes. I've identified a few places below where your logic could be attached to DateRange. In general, unless you're going to use it to isolate pieces of logic, it doesn't make sense to go through the effort of defining a whole separate class.
Classes are loosely coupled mostly - Aside from pulling the check_in / check_out dates from the reservation and examining them manually, the classes don't know much about each other.
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 yes
Wave 2
View available rooms for a given date range yes
Reserving a room that is not available produces an error yes
Test coverage yes
Wave 3
Create a block of rooms yes
Check if a block has rooms yes
Reserve a room from a block yes
Test coverage some missing, particularly in Hotel
Additional Feedback

This looks good overall! I've definitely got some opinions about your DateRange class, and I've identified a number of places where your could could be cleaned up or made DRYer. But, in general this is a pretty well-built solution to a non-trivial problem, and you've managed to keep it organized and readable too. Keep up the good work!

Make sure you check out our reference implementation, particularly the way we've structured and used DateRange, and the way we've handled testing.

@rooms = []
room_num = 0
num_of_rooms.times do |room|
room_num += 1

Choose a reason for hiding this comment

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

Why not something like

@rooms = (1..num_of_rooms).to_a

# ability to reserve a room within a block of rooms
#needs to match the date range of the block
def reserve_room_in_block(check_in, check_out, num_of_rooms)

Choose a reason for hiding this comment

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

I'm not sure I'm convinced by this method signature. What if two blocks have the same checkin/checkout dates and the same number of rooms? Instead, you should pass in either some sort of ID for the block, or the BlockRoom instance itself.

def make_reservation(check_in, check_out, room_num)
if room_availability(check_in, check_out).include?(room_num)
@reservation_made = Reservation.new(check_in, check_out, room_num)
@reservation_collection << @reservation_made

Choose a reason for hiding this comment

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

This method looks good! Very clear what's going on.

# binding.pry
if entry.check_in <= date && entry.check_out >= date
date_list << [entry.room_num, entry.check_in.to_s, entry.check_out.to_s]
end

Choose a reason for hiding this comment

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

This check, that the date falls within the reservation, would be a great candidate for an instance method on DateRange. Then you could say something like if entry.date_range.contains?(date).


@date_range = DateRange.new(check_in, check_out)
@check_in = @date_range.check_in
@check_out = @date_range.check_out

Choose a reason for hiding this comment

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

If you're encapsulating the checkin and checkout dates in a DateRange, the you should not also store them as individual instance variables. If someone wants access to a reservation's dates, they'll have to go through the date range.


it "Checks for invalid date entry - if check in is after check out date" do
check_in_1 = "Sept 9 2017"
check_out_1 = "Sept 8 2017"

Choose a reason for hiding this comment

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

You might include an explicit check here for when the dates are the same. Whether or not it's a legal range, I feel like it's an interesting case.

it "can call on collection of reservations array - will be empty" do
Hotel::Hotel.new(20, 200).reservation_collection.must_be_instance_of Array
Hotel::Hotel.new(20, 200).block_reservation_collection.must_be_instance_of Array

Choose a reason for hiding this comment

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

Two observations about this test:

  • You probably don't want to instantiate two different hotels
  • You don't actually check that the array is empty

You might rewrite it as follows:

it "can call on collection of reservations array - will be empty" do
  hotel = Hotel::Hotel.new(20, 200)

  hotel.reservation_collection.must_be_instance_of Array
  hotel.reservation_collection.length.must_equal 0

  hotel.block_reservation_collection.must_be_instance_of Array
  hotel.block_reservation_collection.length.must_equal 0
end


it "Can return an argument error if room is not available for that date range" do
proc { @bb_hotel.make_reservation('sept 8 2017', 'sept 9 2017', 4)}.must_raise ArgumentError
end ####NOTE##### Not sure how to create a test to check if there is no problem with the code

Choose a reason for hiding this comment

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

Checking for an exception is a good call here. If you're trying to avoid it passing when you've written a bug, a common technique is to define your own exception and look for that instead.

def room_availability(check_in, check_out)
#can be string with dates
rooms_available = @rooms.clone

Choose a reason for hiding this comment

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

I like that you've made getting a list of available rooms its own method - this both DRYs up your code and makes testing easier.

it "Returns the room numbers available for a certain date range" do
@hotel.room_availability('sept 1 2017', 'sept 3 2017').must_equal [1 ,4]
@hotel.room_availability('sept 5 2017', 'sept 6 2017').must_equal [2,3,4]
@hotel.room_availability('sept 7 2017', 'sept 8 2017').must_equal [1,3,4]

Choose a reason for hiding this comment

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

It might be nice to break this up into multiple different it blocks, to make it more obvious why each date range is interesting.

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