Skip to content

Conversation

@cojenco
Copy link

@cojenco cojenco commented Mar 9, 2020

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? Where to hold the reservations and how a hotel block should fit in. Which class should hold this information and which needed to be its own class.
What was a design decision you made that changed over time over the project? At first I had two containers for my reservations. After mid-point review, I decided to remove one of the containers and only let each room hold its own reservations. Looking back, I would refactor that again.
What was a concept you gained clarity on, or a learning that you'd like to share? All the little things and managing dependencies. Also breaking up methods into smaller methods. While breaking up methods and calling methods, then I also gained clarity on which classes should have an inheritance or composition relationship.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? For the DateRange #overlapping method, a nominal case was testing an obvious date range that entirely overlapped and a date range that did not overlap at all.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? For the DateRange #overlapping method, one of the edge case was testing a date range that only overlapped the check-in date or check-out date.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I did stick to the principal of writing the test first, red, green and refactor. I still need more practice on pseudocode.

cojenco added 30 commits March 2, 2020 13:16
…en making a reservation, it will be added to room's tracking collection.
@kaidamasaki
Copy link

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) ✔️
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 ✔️ (Tests on with multiple on the same day are borderline.)
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 (No edge case test.)
creates a block of rooms ✔️
reserves a room from a block (Not implemented.)

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

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!

I am particularly impressed by the way that you went about writing your tests. You had really strong set up and assertion checks throughout your project.

It might make sense to re-think how you implemented blocks. The way you have it you just make a series of unrelated reservations. Once you've reserved a block of rooms you should be able to reserve those rooms through that block, but not outside of it. (They aren't just a bulk purchase of reservations with a discount.)

This project was extremely difficult though and just completing the basic functionality of blocks is a victory!

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

Copy link

@kaidamasaki kaidamasaki left a comment

Choose a reason for hiding this comment

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

Great job! Here are some ways you can tidy up and clarify your code. 😄

Comment on lines +19 to +20
nights = (@end_date - @start_date).to_i
return nights

Choose a reason for hiding this comment

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

You don't need to assign to a variable before returning:

Suggested change
nights = (@end_date - @start_date).to_i
return nights
return (@end_date - @start_date).to_i

Comment on lines +24 to +25
return true if date >= @start_date && date < @end_date
return false

Choose a reason for hiding this comment

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

You can directly return the boolean condition:

Suggested change
return true if date >= @start_date && date < @end_date
return false
return date >= @start_date && date < @end_date

# your library code should assume that it's receiving Date objects to start
def initialize(start_date, end_date)
raise ArgumentError.new("Please pass in Date class instances.") if !(start_date.is_a? Date) || !(end_date.is_a? Date)
raise ArgumentError.new("Live in the present! Dates should not be prior to today.") if start_date < Date.today

Choose a reason for hiding this comment

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

It's helpful to include the bad arguments in message of the ArgumentError:

Suggested change
raise ArgumentError.new("Live in the present! Dates should not be prior to today.") if start_date < Date.today
raise ArgumentError.new("Live in the present! Dates should not be prior to today. Bad start_date: #{start_date}") if start_date < Date.today

@@ -0,0 +1,3 @@

class NoAvailabilityError < StandardError

Choose a reason for hiding this comment

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

Custom exception class! 🎉

attr_reader :id, :start_date, :end_date, :date_range, :room_id, :block
attr_accessor :cost

@@next_id = 1

Choose a reason for hiding this comment

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

Generally we advise against using a class variable. In this case it's not too bad but it would be preferable to have this stored in the SystemCoordinator.

Comment on lines +24 to +26
def list_rooms
return rooms
end

Choose a reason for hiding this comment

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

You don't need both a list_rooms method and an attr_reader on rooms, you should pick one.


def find_reservations_room_date(room_id, date_range)
selected_room = find_room(room_id)
reservations_room_date = selected_room.bookings.reject{|reservation|false == reservation.date_range.overlapping(date_range)}

Choose a reason for hiding this comment

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

This can be simplified using select:

Suggested change
reservations_room_date = selected_room.bookings.reject{|reservation|false == reservation.date_range.overlapping(date_range)}
reservations_room_date = selected_room.bookings.select {|reservation| reservation.date_range.overlapping(date_range)}

status = false if item.date_range.overlapping(given_range)
end
end
available_rooms << room if true == status

Choose a reason for hiding this comment

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

You don't need to compare to true here since status is a boolean value:

Suggested change
available_rooms << room if true == status
available_rooms << room if status

class SystemCoordinator
attr_reader :rooms

@@next_block = 1

Choose a reason for hiding this comment

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

This definitely doesn't need to be a class variable since there will only be one SystemCoordinator instantiated.

rooms_in_block = []

room_array.each do |room|
if room.is_available(date_range) == false

Choose a reason for hiding this comment

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

This can be clarified using an unless:

Suggested change
if room.is_available(date_range) == false
unless room.is_available(date_range)

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