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

Time - Yaz #37

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

Time - Yaz #37

wants to merge 22 commits into from

Conversation

saintmedusa
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?
Choosing where to track reservations - in room or front desk.
What was a design decision you made that changed over time over the project?
Whether or not to have a room class - initially I thought to just track room in reservations and in front desk, but because of the user stories and because I was shooting for single responsibility, it seemed wise to have methods attached to a class.
What was a concept you gained clarity on, or a learning that you'd like to share?
Single responsibility.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case?
I wrote tests for room that make sure a reservation can be added to a room when the added reservation's start date is the same as an existing reservation's end date. This is a nominal case because rooms will commonly have back-to-back bookings.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case?
In hotel block, I tested for the edge case if all rooms in the block are reserved - raise an error. It's an edge case because ideally, the user wouldn't be trying to reserve a room in the block if no rooms are available.
How do you feel you did in writing pseudocode first, then writing the tests and then the code?
It was useful - though sometimes it stopped me from coding when I felt like I should just be getting code out.

saintmedusa and others added 22 commits March 3, 2020 15:50
…and added case coverage to overlap?. Covered and tested all nominal and some edge cases.
…o throw error instead - wrote test and passed.
…for Room constructor and methods, all passed. Editted FrontDesk to reflect these changes - though FrontDesk is still not fleshed out.
…assing tests in front_desk_tests.rb. Note that scafolding for FrontDesk previously included a room id as a parameter to reserve_room - that is now gone. Also added private helper method in FrontDesk: find_room, which replaces the method get_room(id). Additionally, changed functionality of DateRange overlap? to be less complex.
…unctionality the same). Updated FrontDesk#reserve_room to reflect this change. Also changed Room#available? to use any? block instead of none? block. Added FrontDesk#get_avail_rooms(start,end) and thourough tests in front_desk_tests (all passing). Updated tests for Room to not trip on Argument error for unavailable room in the process of testing Room#get_reservations(start, end_date).
…en no rooms are available, and successfully reserves a room when all rooms have at least one reservation.
…meter rate(with default value 200) to Reservation, and changed error messages in FrontDesk and Room to be more specific.
…m). Wrote extensive tests in block_tests.rb.
…oved attr_reader and created a custom reader method that doesn't show user the nil values that booked rooms leave behind
…so that FrontDesk contains no direct references to Reservation - only through room. With this refactor, Room#add now has capability to create a reservation with the room_rate, if provided.
…nd unused variable warnings in block_test and front_desk_test
is this possible?
@beccaelenzil
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 ✔️

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 ✔️
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 see in line comment
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

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 wrote extremely comprehensive tests. Furthermore, you've made design decision and written code that elegantly implements tricky logic. I've left a few in-line comment for you to review about ways you might consider refactoring. Overall it is clear that the learning goals around TDD and object oriented design were met. Keep up the hard work!

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
Logical/Organized

@@ -0,0 +1,49 @@
require 'date'
module Hotel
class InvalidDateError < StandardError

Choose a reason for hiding this comment

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

Nice use of a custom exception.


end

def overlap?(other)

Choose a reason for hiding this comment

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

I like your design choice to have Reservation and Block inherit from DateRange. I think I understand your logic here. Front_desk will invoke overlap? on instances of reservation with date_range as the argument, yea? Given that you're using the method in a child class (reservation), but other is a DateRange, you may consider adding a comment to explain this use case to increase readability. Also, correct me if I'm mis-understanding your logic.

return reservations_at_date
end

private

Choose a reason for hiding this comment

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

Nice use of a private helper method.

@@ -0,0 +1,109 @@
require_relative "test_helper"

describe Hotel::Block do

Choose a reason for hiding this comment

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

These tests are really comprehensive. Nice work!

end

describe "nights" do
it "returns the correct number of nights" do

Choose a reason for hiding this comment

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

Wow. Comprehensive! I see you're testing different cases with each assertion here. You might consider splitting these up. For Instance

 it "returns the correct number of nights when the reservation spans the new year" do
      cont_start = Date.new(2016, 12, 29)
      cont_end = Date.new(2017, 01, 01)
      range = Hotel::DateRange.new(cont_start, cont_end)
      expect(range.num_nights).must_equal 3
end

 it "returns the correct number of nights when the reservation spans a change in month" do
      cont_start = Date.new(2017, 01, 01)
      cont_end = Date.new(2017, 02, 01)
      range = Hotel::DateRange.new(cont_start, cont_end)
      expect(range.num_nights).must_equal 31
end

expect(rooms.any? {|room| room.reservations.include?(res5)}).must_equal false
expect(rooms.any? {|room| room.reservations.include?(res6)}).must_equal false
end

Choose a reason for hiding this comment

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

You check that reserve_room raises an Exception if there are no available rooms. Nice work! It's also important to test this edge case in available_rooms. What does available_rooms return when there are no available rooms?

end
expect{@front_desk.reserve_room(Date.new(2020, 01,01), Date.new(2020,01,03))}.must_raise ArgumentError
end

Choose a reason for hiding this comment

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

Your block tests are quite comprehensive. Now that you have implemented blocks, you should also add a test here to make sure you can't reserve a room that's part of a block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants