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

Carets- Julia Meier- Hotel #43

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

Carets- Julia Meier- Hotel #43

wants to merge 42 commits into from

Conversation

julmeier
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? In creating the initial design, I debated as to which class should handle making reservations. I ultimately chose the Hotel class to check, store and modify reservations, because I wanted it to mimic real life in that, "a hotel makes reservations/ has rooms". The reservation, block and room classes did not take on any of this functionality. I could use some practice on how to handle exceptions.
Describe a concept that you gained more clarity on as you worked on this assignment. This assignment really helped me understand how and when to make objects, and how to call them from other classes and make modifications.
I wish I could have gotten to the optional assignment of creating a CLI, because I think it would have helped me better understand how to implement rescuing exceptions- right now, I just created custom exceptions, but haven't yet implemented a course of action in how these errors are rescued.
Describe a nominal test that you wrote for this assignment. One nominal test of my hotel class looked to see that the first reservation of a block was unassigned and then changed to assigned after the assign_block_reservation method.
Describe an edge case test that you wrote for this assignment. I wrote an edge case test about the assign_block_reservation method that checked to see that, after three block reservations were change to "assigned", that the fourth tim the method was called, there was only 1 reservation left as "unassigned". This test was extremely helpful as I found out that my find_unassigned_block_reservations method in the code was not correctly identifying unassigned reservations. Before I fixed it, it would return all reservations in a block - the assign_block_reservation method was not effectively changing the status of the reservations.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? It's helpful to write out the intention and general idea of what you're trying to accomplish first; it's easy to just start coding away so writing pseudocode first helped to slow me down.

… initialize. Removed self.all method. Added list_room method- passes tests
…stance variable of hotel that can be used for all the tests
… of a reservation. Added a Custom_Exceptions file
…ount for search dates that fell exactly on the checkin and checkout dates of existing reservations.
….added a status attribute to the reservations class and altered find_rooms_available method in the hotel class to consider the status attribute in assessing a room's availability
@CheezItMan
Copy link

Hotel

What We're Looking For

Feature Feedback
Baseline
Used git regularly A lot of commits and good messages, that's great!
Answer comprehension questions Check, you did implement a rescue in your Reservation class which caught an ArgumentError and then generated a custom error of your own.
Design
Each class is responsible for a single piece of the program You've got almost all the functionality of your project in the Hotel class. You should allocate actions that go along with the concept of reservation or block in those objects. Like rooms remaining in a block, or total cost for a reservation.
Classes are loosely coupled They're loosely coupled because none of the classes outside of Hotel is really doing business logic.
Wave 1
List rooms Check, but see my notes in the Hotel class.
Reserve a room for a given date range Check
List reservations for a given date Check
Calculate reservation price Check, but it's done via very tight coupling between Hotel and Reservation.
Invalid date range produces an error There's no check for if a reservation's check-in date is before the check-out date.
Wave 2
View available rooms for a given date range Check
Reserving a room that is not available produces an error It picks a random room, but it does check to see if none are available
Wave 3
Create a block of rooms Check
Check if a block has rooms Check
Reserve a room from a block Check via find_unassigned_block_reservations
Test coverage 99%!
Additional Feedback Take a look at the Sandy Metz book again along with my in-line comments. You've got some textbook examples of tight coupling, and I highlighted at least one. You also have all the work being done in MyHotel instead of providing helper methods where appropriate in the other classes. Think about what you should be able to ask a reservation or a block. What questions should a reservation be able to answer? Not a bad submission, but a difficult design to change or adapt due to all the work being very nested into MyHotel.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

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

A few in-code notes.


attr_accessor :check_in_date, :check_out_date, :room, :HOTEL, :cost, :status, :block_reserved

HOTEL = Hotel_Chain::MyHotel.new

Choose a reason for hiding this comment

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

This looks like you can only have ONE hotel EVER.

module Hotel_Chain
class Reservation

attr_accessor :check_in_date, :check_out_date, :room, :HOTEL, :cost, :status, :block_reserved

Choose a reason for hiding this comment

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

You have a lot of attr_accessor methods here, but they don't all get set values, like cost. How does that get calculated?

You should either have a method that does the calculation for the cost of the reservation or set the cost in the initialize method.

lib/hotel.rb Outdated
reservations_on_date.each do |reservation|
array << "Room #{reservation.room.room_id} is reserved from #{reservation.check_in_date} to #{reservation.check_out_date}"
end
ap array

Choose a reason for hiding this comment

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

When you turn things in, it's best to take out extraneous puts or ap commands. It makes running things more messy than it would be otherwise.

lib/hotel.rb Outdated
require 'pry'

module Hotel_Chain
class MyHotel

Choose a reason for hiding this comment

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

Why not call this Hotel instead of MyHotel? MyHotel sounds like it's an individual Hotel instance rather than a class.

lib/hotel.rb Outdated
module Hotel_Chain
class MyHotel

attr_reader :array_of_rooms, :reservations_array, :blocks_array

Choose a reason for hiding this comment

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

You should probably just name these, rooms, reservations, or blocks because you might in the future change how you implement these data structures and you want to separate implementation from how they're used.

Also do you want to give the user direct access to the rooms and reservations and blocks, instead of making them go through your methods. With this they could change them directly bypassing MyHotel methods.

lib/hotel.rb Outdated
def find_reservations_by_date(date)
reservations_on_date = []
@reservations_array.each do |reservation|
if (reservation.check_in_date...reservation.check_out_date).cover?(Date.strptime(date, "%m/%d/%Y"))

Choose a reason for hiding this comment

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

Just a note, this makes a new Date object each time the loop iterates. You instead create one before the loop and then use it here.

Just a bit of optimization.

More seriously, this method works directly with the Reservation object's data attributes, instead this logic should go into the Reservation class and Hotel should simply ask, ""Hey does this date overlap with you?" using an instance method and should get back a true/false response.

This is an example of tight coupling.

lib/hotel.rb Outdated
new_reservation.room = @array_of_rooms[0]
@reservations_array << new_reservation
return new_reservation
elsif @reservations_array.length > 0

Choose a reason for hiding this comment

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

This elseif is unnecessary, else would be enough since if it's not 0 it's greater than 0.

end

def find_rooms_available(check_in_date, check_out_date)
unavailable_rooms = []

Choose a reason for hiding this comment

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

This method seems overly complicated.


def reserve_block(party_name, check_in, check_out, no_of_rooms, room_rate)
if no_of_rooms > 5
raise ExceededRoomLimitForBlocksError

Choose a reason for hiding this comment

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

Good use of a custom Error.

else
no_of_rooms.times do |room|
new_reservation = store_reservation(check_in, check_out)
new_reservation.room.rate = room_rate

Choose a reason for hiding this comment

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

room rate should be passed in when you create the reservation.

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