Skip to content

Conversation

@kelsk
Copy link

@kelsk kelsk commented Sep 9, 2019

Hotel

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What was a design challenge that you encountered on this project? Creating an adequate, adjustable, comprehensive design in advance is still my biggest design challenge. I thought the overall design seemed simple when I diagrammed it, but once I'd gotten deep into writing code I realized it was much more complex than I had anticipated. I very much wish I would have read POODR chapter 3 before I had begun designing the project! The lessons about managing dependencies were extremely relevant to my hotel project, but I didn't read the chapter until I had done too much work to start over. I think I have a tendency to under-design, so I need to not be afraid of over-designing.
What was a design decision you made that changed over time over the project? I had one large method for creating a reservation in the reservation manager class, but I decided to break it down into several smaller methods. This ended up working well when I introduced the block reservations and was able to refactor only the methods that needed to be accessed by the block.
What was a concept you gained clarity on, or a learning that you'd like to share? I'll reiterate how important the POODR chapter on managing dependencies was for me in this project. I understand how essential it is to keep classes, methods, and objects as loosely coupled as possible to keep them flexible and reusable. I still don't always know how best to accomplish that in my code, but I'll be working on it.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? A nominal test case that I wrote is for creating a new reservation (reservation_manager_test.rb:37). Just a basic, normal reservation.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? An edge case that I tested is for rejecting a reservation of a Block in a Block (block_test.rb:50). It's an edge case because an interface ideally wouldn't even allow a block to be reserved in a block.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? For wave 1 and most of wave 2, mostly great! I breezed through pseudocode and tests for wave 1, and went lighter on pseudocode and heavier on tests for wave 2. For wave 3, I skipped pseudocode almost entirely, possibly to my detriment.

kelsk added 22 commits September 3, 2019 14:21
@tildeee
Copy link

tildeee commented Sep 17, 2019

Hotel

What We're Looking For

Test Inspection

Workflow yes / yes but no test / no
Wave 1
List rooms yes
Reserve a room for a given date range yes
Reserve a room (edge case) 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

Code Review

Baseline Feedback
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
Fundamentals
Names variables, classes and modules appropriately yes
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 yes
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 maybe? not sure if these are future or past changes hehe

Overall Feedback

Great work overall! You've built your first project with minimal starting code. This represents an incredible milestone in your journey, and you should be proud of yourself!

Your code looks great! Overall, it's well-written code; it's clean, logical, readable, and with great code style. Overall, I think you made great decisions; your details in optional arguments and class and method design, thorough test cases (and a lot of great edge cases), and helper methods that broke up functionality are all great habits that I hope you keep!

Overall, one big comment for improvement is about test organization: If the "Act" that you're testing is a method that belongs in one class, then that test belongs to that class's tests, even if it's conceptually about a different class. A huge thing you did was test making reservations in Blocks/about Blocks in the block tests, even though it's a ReservationManager method. Just a note for next time!

Also, I have a few comments for small suggestions of improvement attached to your code.

This all being said, you did a great job on this project, and I have a lot of confidence in your fundamentals! Keep it up!

module Hotel
class ReservationManager

attr_accessor :rooms, :reservations, :blocks
Copy link

Choose a reason for hiding this comment

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

I'd probably use attr_reader here! (Your tests still pass if it's attr_reader)

@calendar = calendar
end

def request_reservation(start_date, end_date, type: :room, block_id: nil, amount: 1)
Copy link

Choose a reason for hiding this comment

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

This method is great!

return block
end

def create_reservation(start_date, end_date, room, discount: discount)
Copy link

Choose a reason for hiding this comment

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

I like these helper methods!!

available_rooms_by_id = available_rooms_by_id - [reservation.room.id]
end
end
if available_rooms_by_id[0] == nil
Copy link

Choose a reason for hiding this comment

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

Minor suggestion: consider refactoring this so it's more clearly checking that the array is empty, like .empty? or .length == 0

end
end
if available_rooms_by_id[0] == nil
return [nil]
Copy link

Choose a reason for hiding this comment

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

Minor suggestion: Instead of returning [nil], maybe an empty array would feel more appropriate

if room.id == id
rooms_by_id << room
end
end
Copy link

Choose a reason for hiding this comment

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

Consider using .select instead here! That method should give you back an array of everything that matches your criteria

end

it "adds up to 5 rooms to a Block" do
new_block = @hotel.request_reservation(Date.parse('2019-10-31'), Date.parse('2019-11-04'), type: :block, amount: 5)
Copy link

Choose a reason for hiding this comment

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

Because the "Act" step is a method that belongs to a ReservationManager (aka the method request_reservation), this test should be moved to the reservation_manager_test

expect{@hotel.request_reservation(Date.parse('2019-10-31'), Date.parse('2019-11-04'), type: :block, amount: 5)}.must_raise ArgumentError
end

it "raises an exception if adding a Block to a Block" do
Copy link

Choose a reason for hiding this comment

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

Nice!


# adds conflicting reservations to test data
14.times do |i|
@test_reservations << Hotel::Reservation.new(Date.parse('2019-10-31'), Date.parse('2019-11-04'), @test_rooms[i + 6])
Copy link

Choose a reason for hiding this comment

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

Nice setup! This is a very subtle thing, but... you add test reservations to your test reservation manager by shoveling in Reservations into @test_reservations. Instead of relying on shoveling into @test_reservations, in this case, it may be good in the setup to literally use @hotel.request_reservation so you rely on the reservation manager's interface to add reservations, without relying on knowing that it's an array (that can be modified by reference)

end

def get_date_range(start_date, end_date)
if !valid_start_date?(start_date)
Copy link

Choose a reason for hiding this comment

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

Clever, but was this a requirement for our project? :)

Also, consider this: What happens to your tests in a year?

Otherwise, I really like how this method/class is structured: it separately has methods to determine if one property is valid. Keep this pattern up!

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