Skip to content

Conversation

@seaweeddol
Copy link

Assignment Submission: Hotel

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
What was a design challenge that you encountered on this project? I was not always sure where to put my methods. There were times that I would add it to one class, and then realize that I couldn't access a variable I needed easily and move it to another class. My HotelManager ended up holding most of the methods, and I think it would be better to move some of these into their related classes to follow the principle of single responsibility better.
What was a design decision you made that changed over time over the project? When I first started drawing out my structure, I did not have a DateRange class. I ended up adding this after looking at the Ada scaffolding and think this really helped separate responsibilities out from my Reservation class. There were also a few methods that I started writing and spent a lot of time on, but ended up scrapping because they weren't working out.
What was a concept you gained clarity on, or a learning that you'd like to share? I learned a lot about testing during this project. I spent a lot of time troubleshooting tests that weren't working as expected and couldn't figure out if it was my test or my code that was wrong, and several times it ended up being that my test variables weren't being called the way I expected because I had them in before or lets.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? For my Room check_availability tests, I had a "returns true if room has no reservations" test. This is a nominal test as it's expected that if there are no reservations then the room is available.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? For my Room check_availability tests, I had a "returns true when last day of reservation is same as first day of new reservation" test. This is an edge case because it is technically included in the date range, but does not make the room unavailable since the guest should be checked out by the time the next guest checks in.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I did not do a good job writing pseudocode first. I wrote out most of my wave 1 and wave 2 structure on paper and wrote some pseudocode when I was stuck, but mostly just did tests and code. I wrote tests before code most of the time, but adding pseudocode would have helped me gather my thoughts more. I have a habit of jumping into a project but getting stuck on logic because I haven't written anything out in pseudocode.

@tildeee
Copy link

tildeee commented Mar 20, 2020

Hotel

Section 1: Major Learning Goals

Criteria yes/no, and optionally any details/lines of code to reference
Practices SRP by having at least two separate classes with distinct responsibilities, and test files for these two classes ✔️
Overall, demonstrates understanding instance variables vs. local variables. (There aren't unnecessarily too many instance variables, when it should be a local variable) ✔️
For each test file, tests demonstrate an understanding of instantiating objects properly, and using Arrange-Act-Assert ✔️
Practices pseudocode and TDD, and reflected on it by filling out the reflection questions ✔️, :)
Practices git with at least 15 small commits and meaningful commit messages ✔️

Section 2: Code Review and Testing Requirements

Criteria yes/no, and optionally any details/lines of code to reference
There is a class that represents a reservation, and a second class that holds/manages a collection of reservations through composition (instance variable) ✔️, Room manages reservations
The logic for checking if a reservation's date overlaps with another reservation's date is complex logic that is separated into method(s) (and potentially class(es)) ✔️
The logic for checking if a reservation's date overlaps with another reservation's date has unit tests ✔️
All of the given tests run and pass ✔️
A test coverage tool is installed and used, and shows 95% test coverage ✔️, 100%!!!!

Section 3: Feature Requirements

Feature Requirement: There is a method that... yes/no
gives back a list of rooms, and it's tested ✔️
creates a specific reservation for a room for a given date range, and it has nominal test cases ✔️
creates a specific reservation for a room for a given date range, and it tests an edge case, such as no available room, or invalid date range ✔️
gives back a list of reservations on a given date. Its tests include a test that makes several reservations for a given date ✔️, yes! list_reservations_by_date
calculates the total price for a reservation ✔️
gives back a list of available rooms for a given date range, and it has nominal test cases ✔️
gives back a list of available rooms for a given date range, and it has edge test cases, such as no available room, or invalid date range ✔️
creates a block of rooms ✔️
reserves a room from a block ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 14+ total in all sections ✔️
Yellow (Approaches Standards) 9-13 total in all sections
Red (Not at Standard) 0-8 total in all sections, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Additional Feedback

Jessica! Great work on this project! Hotel is a huge project, and you did an incredible job of going from essentially nothing to a very fully implemented set work of work.

I can really clearly see your very clean and direct code style that really prioritizes readability. I thought everything flowed and made sense very clearly; I think that your tests are so incredibly well-written! I think that you are thoughtful about the logic you write, and you clearly refactor; your use of helper methods, enumerable methods, post-fix conditionals, optional keywords, all balanced with pretty direct logic reads so well.

I have a few comments with ideas for better syntax (namely the let syntax in tests) and some small design stuff. Let me know if you have questions on that.

Overall, you did a great job with this project. Well done!

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized

return @rooms
end

def reserve_room(date_range, room = nil)
Copy link

Choose a reason for hiding this comment

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

Nice use case of the optional parameter! Makes total sense

Comment on lines +39 to +41
reservation = Reservation.new(date_range, @total_reservations, picked_room.number, picked_room.cost)

find_room(reservation.room_number).reservations << reservation
Copy link

Choose a reason for hiding this comment

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

A very small design thing to consider in the future:

Since your HotelManager class manages number of total reservations, it makes sense that @total_reservations += 1 logic lives here. But since Room manages reservations, too, it might be interesting to see the above lines take more of an approach to:

  1. Find the right room in HotelManager, THEN
  2. Tell the right room to create and add a reservation.

I would personally achieve this by doing the find_room method first, and then creating an instance method in Room to create the Reservation object instance and shovel it into its reservations array. This is a thought for a future refactoring!

Comment on lines +12 to +17
let(:rooms) {
room1 = Hotel::Room.new(1, 200)
room2 = Hotel::Room.new(2, 200)
room3 = Hotel::Room.new(3, 200)
rooms = [room1, room2, room3]
}
Copy link

Choose a reason for hiding this comment

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

the let syntax is super super super weird. It wants to assign the local variable to the last line evaluated in the let block.

This is all to say, in this block that defines a variable named rooms (determined by the line let(:rooms)), you technically don't need the rooms = part on line 16. This will help get rid of a warning you have when you run rake that says .../hotel/test/hotel_manager_test.rb:16: warning: assigned but unused variable - rooms

When you run rake, if you see a bunch of these warnings about assigned but unused variables, and it's about a variable in a let block, try deleting the var_name = part on the last line. Ruby is trying to say that that's redundant with the let block syntax.

Comment on lines +337 to +339
(3..20).each do |i|
@hotel_manager.reserve_room( @date_range, i)
end
Copy link

Choose a reason for hiding this comment

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

Nice! Perfect approach to this test!

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