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

Ports - Elle #38

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

Ports - Elle #38

wants to merge 24 commits into from

Conversation

dev-elle-up
Copy link

@dev-elle-up dev-elle-up commented Mar 18, 2019

Hotel

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What was a design challenge that you encountered on this project? One challenge was deciding what to do with the concept of a room. I considered making it a class but this didn't make sense for my design. I considered having the manager make the rooms but that gave manager more than one responsibility. I settled on making a Room module and this worked well for my design.
What was a design decision you made that changed over time over the project? Originally the functionality of #ck_avail and #get_insert_index were going to be in the #make_res_for_room method. I decided to put them in their own methods because it's easier to understand what's happening and these methods are now usable on their own.
What was a concept you gained clarity on, or a learning that you'd like to share? I gained some clarity on how to access methods from outside of a class. The concept also applied to using before-do (which works more like a class) and let (which works more like a method). I'm still not 100% solid on these concepts and I think they will become clearer with continued practice and review.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? A nominal test I wrote is "Add a new reservation to an available room's reservations array". It adds two reservations to the same room on dates that are separated by a few days in between. This is a very common, normal use of the system, which makes this a nominal case.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? I wrote a test (res6_overlap_start) which tries to make a reservation with an end date that is contained within an existing multi-day reservation but with a start date that was available. This was an edge case because it tested a situation that could pass if only one end of the date range was tested. In a way, it makes sure the same logic used for sorting the reservations by date is not being used by the availability checker.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I feel I was largely successful in using this process. I did this for almost every step and I think it helped achieve a high coverage (codecov).

…ss and Manager class. Created tests for creation of rooms array. Generally got this much working.
…st of the reservation. Wrote tests for same. All passing.
…ed), and add the reseveration object to the array associated with (value of) the room number's key in rooms_reservations_hash. Test added for same, passing.
…urn a list (array) of rooms that have a reservation on that date. Along with the room number, the full date range of the reservation is returned.
…te range' test. The find_avail_fooms_for_dates method searches each array of reservations to find gaps between bookings and adds the associated available room number to an array, which is returned.
…e other small adjustments to clean up comments.
…ates. This is broken out of the previous function to allow for use in multiple places. Also added checks for 0 and 1 item arrays, as well as checking for availability before first reservation or after last reservation.
…eing added to the available rooms array. Everything else is working. Next: delete some things and re-write them.
… now see a list of rooms that are not reserved for a given date range, reserve an available room, and get an exception error when trying to make a reservation for an unavailable room. Need to build out more tests to check edge cases.
…both for raising exceptions and for making reservations with shared check-in/check-out dates. (Wave 2 complete.)
@CheezItMan
Copy link

Hotel

What We're Looking For

Feature Feedback
Baseline
Used git regularly Good number of commits and good commit messages
Answer comprehension questions Check, I'm glad you got more comfortable with calling methods and breaking things down into smaller steps.
Design
Each class is responsible for a single piece of the program Check
Classes are loosely coupled Your manager class is doing a bit too much of the work. Consider offloading some of it to Reservation. See my inline notes.
Wave 1
List rooms Check
Reserve a room for a given date range Check
List reservations for a given date Check
Calculate reservation price Check
Invalid date range produces an error Check
Wave 2
View available rooms for a given date range Check
Reserving a room that is not available produces an error Check
Test coverage 100%
Wave 3 INCOMPLETE
Create a block of rooms
Check if a block has rooms
Reserve a room from a block
Test coverage
Fundamentals
Names variables, classes and modules appropriately Check
Understanding of variable scope - local vs instance Check
Can create complex logical structures utilizing variables Check
Appropriately uses methods to break down tasks into smaller simpler tasks Check
Understands the differences between class and instance methods Check, see my notes on the Room class
Appropriately uses iterators and Enumerable methods Check
Appropriately writes and utilizes classes Check
Appropriately utilizes modules as a namespace Check
Wrap Up
There is a refactors.txt file MISSING
The file provides a roadmap to future changes MISSING
Additional Feedback Not bad, you hit many of the learning goals of the project, but obviously didn't get to wave 3. See my inline notes and ask any questions you have. While you didn't get to wave 3 and blocks you did well on waves 1 & 2.


def self.make_rooms
rooms_res_hash = {}
(1..NUM_OF_ROOMS).each { |i| rooms_res_hash[i] = [] }

Choose a reason for hiding this comment

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

Interesting a hash of rooms with the number being the key, and the value being an array of reservations. Nice!

attr_accessor :rooms_reservations_hash

def initialize
@rooms_reservations_hash = Room.make_rooms

Choose a reason for hiding this comment

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

I like having this class method in Room. However since you never make an instance of the Room class, maybe instead make Room a module, or have make_rooms as a private factor method in Manager.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Chris. Room actually is a module! :-D It's in the room.rb file. Is this an acceptable setup or would it be better to eliminate the room.rb file and move that code into manager.rb?

I like having this class method in Room. However since you never make an instance of the Room class, maybe instead make Room a module, or have make_rooms as a private factor method in Manager.

end
end

return res_on_date # array with [[1, "2019-06-10 through 2019-06-12"], [room_num, "date through date"], etc]

Choose a reason for hiding this comment

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

This works, but I'd suggest that it would be easier as an array of hashes with the keys room and reservation_date, just for readability.

lib/manager.rb Outdated
(res_0.ckout_date <= ckin) || (ckout <= res_0.ckin_date) ? true : false
else # there is more than one reservation in the array
# check left and right ends of the reservation array
return true if (ckout <= res_0.ckin_date)

Choose a reason for hiding this comment

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

Your code maintains your reservations listed in order, later if you take advantage of things Shruti will teach you like binary search some actions like finding a reservation or finding overlapping reservations may be more efficient.

Nice

return avail_rooms
end

def print_available_rooms_for_dates(ckin, ckout)

Choose a reason for hiding this comment

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

In the future I'd recommend that you separate the roles of printing information and managing rooms and reservations. Printing things out is something I'd do in a driver method or class.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Chris, are you talking about lines 75 & 76? I think those were a couple of puts statements that I was using to test/debug and just forgot to comment them out. My print method is directly below, starting on line 87. Is this what you mean, or am I still missing a concept? I think you might be saying that my Manager class is currently acting as a driver class as well as validating the availability of the reservation dates.

Choose a reason for hiding this comment

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

This method print_available_rooms_for_dates is doing printing that should probably be pulled into a separate module

return avail_rooms
end

def get_insert_index(res_array, new_res)

Choose a reason for hiding this comment

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

Just a note for CS Fun. You could speed this up with a binary search. Something to remember.

module Hotel
class Reservation
attr_reader :ckin_date, :ckout_date, :date_range_string_array, :num_nights_of_stay, :base_cost

Choose a reason for hiding this comment

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

Consider moving the checking for overlapping a date with the reservation to this class, so it could handle more actions that deal with a specific reservation. It might simplify your manager class.

Also calculating the cost of a reservation is probably best done as a method just in case the dates change (extremely minor point).

expect(this_manager.rooms_reservations_hash[9][0].ckin_date.to_s).must_equal "2019-05-29"
end

it "Reservation is allowed if check in or check out is same as another reservation's check in or check out date" do

Choose a reason for hiding this comment

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

Good test! 👍

…nto Reservation in order to decouple. Pulled the length of stay and cost calculations out of the initialize method and into instance methods. Also renamed self.get_date_conflicts to self.ck_dates_are_available for clarity and increased intuition about what is returned.
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