Skip to content

Karla G - Sockets#42

Open
kguadron wants to merge 23 commits intoAda-C11:masterfrom
kguadron:master
Open

Karla G - Sockets#42
kguadron wants to merge 23 commits intoAda-C11:masterfrom
kguadron:master

Conversation

@kguadron
Copy link
Copy Markdown

Hotel

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What was a design challenge that you encountered on this project? An initial design challenge I faced was deciding which actions (methods) belong to which classes. I encountered these same questions in wave three when creating the hotel block.
What was a design decision you made that changed over time over the project? When I planned out wave three, I intended to have a BlockReservation class that inherited from the Reservation class. I changed my mind as I built the Block class.
What was a concept you gained clarity on, or a learning that you'd like to share? The whole process of designing and building a system is much clearer to me. At the beginning of the project, I felt lost with that and by Wave 3 I was able to make decisions with more intentionality.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? An example of a nominal test I wrote was testing to see if objects were an instance of the intended class.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? An edge case I tested for my reserve_block_room was checking if the block id existed or not.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I further developed that skill during this project. Following the trend I explained before, during the beginning phases it felt more tenuous and by Wave 3 I pseudocoded everything and felt it really helped with executing the writing of the code.

kguadron added 22 commits March 11, 2019 10:57
…spec_helper. Created initialize method for Room class
…ly be used to determine which room a guest will be assigned to when a resewrvation is made
…l as accompamying specs. Created block class and tests
@droberts-sea
Copy link
Copy Markdown

Hotel

What We're Looking For

Feature Feedback
Baseline
Used git regularly yes
Answer comprehension questions yes
Design
Each class is responsible for a single piece of the program yes
Classes are loosely coupled yes
Wave 1
List rooms yes
Reserve a room fr 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 yes
Fundamentals
Names variables, classes and modules appropriately mostly
Understanding of variable scope - local vs instance yes
Can create complex logical structures utilizing variables yes
Appropriately uses methods to break down tasks into smaller simpler tasks yes
Understands the differences between class and instance methods yes
Appropriately uses iterators and Enumerable methods mostly
Appropriately writes and utilizes classes yes
Appropriately utilizes modules as a namespace yes
Wrap Up
There is a refactors.txt file yes
The file provides a roadmap to future changes yes
Additional Feedback Excellent job overall. This code is well-organized, well-written, and well-tested. I've left a number of inline comments, but in general I like what I see. Keep up the hard work!

Comment thread lib/hotel.rb
def see_reservations_by_date(date)
this_dates_reservations = []
@all_reservations.each do |reservation|
this_dates_reservations << reservation if reservation.start_date == date
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The .select enumerable might be helpful to clean up this code.

Comment thread lib/hotel.rb
def see_available_rooms_by_date(possible_start_date, possible_end_date)
these_dates_available_rooms = []
@all_rooms.each do |room|
these_dates_available_rooms << room if room.date_available?(possible_start_date, possible_end_date)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On line 34, I like that you call room.date_available? instead of having a bunch of date math here in Hotel. This is what Metz is talking about when she says you should "ask for what instead of telling how".

Comment thread lib/hotel.rb
def room_available?(new_start_date, new_end_date)
@all_rooms.each do |room|
return room if room.date_available?(new_start_date, new_end_date)
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In Ruby, ending a method name with a question mark implies that it returns either true or false, but this method may return an instance of Room. A better name might be find_available_room.

Comment thread lib/hotel.rb
def hold_block(start_date, end_date, room_collection)
room_collection.each do |room|
raise ArgumentError, "Room #{room.number} is already in a block" if room.block_id != nil
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't know that I agree with the idea of storing the block_id as an instance variable on the Room. That means that each room can only ever be included in one block. However, blocks don't last for ever - they're for a set amount of time, and on other dates the room should be free to be included in other blocks.

Comment thread lib/hotel.rb
if desired_block == nil
raise ArgumentError, "The block entered does not exist or it does not have any rooms available for reseervation"
elsif desired_block.room_still_available?
reservation = HotelSystem::Reservation.new(room: room, start_date: start_date, end_date: end_date, guest: guest)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This will not raise an exception if the block is full. To do so, you would need code like this:

if desired_block == nil || desired_block.room_still_available?
  raise ArgumentError #...
else
  # ...

However, I would prefer you split the two cases and provide a little more detailed information in your error message.

Comment thread lib/reservation.rb

def calculate_cost
return ("%.2f" % ((@end_date - @start_date) * @price)).to_f
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like the decision to make this a method rather than storing the cost as an instance variable. That way if the number of nights or the cost per night were to change (say in a future version of the program), the total cost will automatically be correct.

Comment thread lib/room.rb
if possible_start_date == reservation.start_date
return false
elsif reservation.start_date < possible_start_date && possible_start_date < reservation.end_date
return false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can simplify all of this complex conditional logic into one line! See the instructor implementation.

Each of these would make an excellent test case though.

Comment thread spec/hotel_spec.rb
hotel.reserve_room(
room,
Date.new(2019, 3, 10),
Date.new(2019, 3, 13),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You do a lot of repeated setup work throughout these tests. Would it be possible to consolidate this into a shared before block or something similar?

Comment thread spec/hotel_spec.rb
describe "room_available? method" do
before do
@hotel = HotelSystem::Hotel.new
@hotel.all_rooms.slice!(2..19)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a clever way to make this test work. Another option would be to pass in the number of rooms to the Hotel constructor, possibly with a default value of 20.

Comment thread spec/room_spec.rb
it "returns false if the possible start date matches the start date of the reservation" do
expect(@room.date_available?(Date.new(2019, 3, 11), Date.new(2019, 3, 12))).must_equal false
expect(@room.date_available?(Date.new(2019, 3, 11), Date.new(2019, 3, 14))).must_equal false
expect(@room.date_available?(Date.new(2019, 3, 11), Date.new(2019, 3, 15))).must_equal false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work nailing all of these test cases.

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