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

quin - time #36

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

quin - time #36

wants to merge 11 commits into from

Conversation

quinqu
Copy link

@quinqu quinqu 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? pretty much all of it, i had a lot of trouble implementing room block
What was a design decision you made that changed over time over the project? I wanted more stuff in the room and reservation class but most of the functions remained in the hotel class
What was a concept you gained clarity on, or a learning that you'd like to share? I really figured out that more design planning is needed for OOP
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? I stored reservations for room in an array in the room object, I tested the length of reservations array of a room once. I also checked if an object was an the object intended. a nominal case is when
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? An edge case test I created was making sure my code could start a reservation when the same one ends. When there is an extreme operating parameter is when there is an edge case (cite: stackexchange.com)
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I think I did terrible at the pseudocode and just jumped in. Writing tests was the easiest part of this assignment. I don't think my project structure was very great and I should have actually redesigned it, but it was too late.

@kaidamasaki
Copy link
Contributor

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 Didn't pseudocode. Please try to practice this in the future. It's easier to redesign psuedocode than a full implementation.
Practices git with at least 15 small commits and meaningful commit messages Going forward please commit more often and leave more detailed messages. This will help you going forward, especially in group projects.

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 ✔️ Tests only pass if I set my clock back, but they do all pass on March 9th.
A test coverage tool is installed and used, and shows 95% test coverage ✔️ Tests only pass if I set my clock back, but they do all pass on March 9th.

Section 3: Feature Requirements

Feature Requirement: There is a method that... yes/no
gives back a list of rooms, and it's tested No tests.
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 Not enough edge cases tested.
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 Not implemented.
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 reflected upon your code and the quality of the tests that do exist.

I do see some room for improvement around testing edge cases and making sure to take a step back and refactor as code starts to get unwieldy.

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
Contributor

@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.

Good job. Some parts of your design were a little messy but it seems like you're aware of that based on your refactors.txt.

Here are some tips for how to clean up your code.

Comment on lines +21 to +23
if Date.today > start_date || Date.today > end_date
raise ArgumentError.new("Invalid date, you can't start or end a reservation in the past")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to have a check like this please make sure that your example dates in your tests are in the future. (Either by placing them far in the future or making them relative to Date.today.)

Several of your tests fail because dates are now in the past.

describe "initialize" do
it "I can access the list of all of the rooms in the hotel" do
hotel = HotelSystem::Hotel.new
hotel.must_be_instance_of HotelSystem::Hotel
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use expect when writing assertions:

Suggested change
hotel.must_be_instance_of HotelSystem::Hotel
expect(hotel).must_be_instance_of HotelSystem::Hotel

Minitest generates lots of warnings otherwise. (And in future versions of Minitest this won't work.)

Comment on lines +1 to +26
module HotelSystem
class DateRange
attr_accessor :start_date, :end_date

def initialize(start_date, end_date)
@start_date = start_date
@end_date = end_date
end

def overlap?(other)
return false
end

def include?(date)
return false
end

def nights
return 3
end

end



end
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it's left over from the scaffolding.

In the future if you're not using code you should remove it.

Comment on lines +54 to +58
@rooms.each do |room|
if room_number == room.room_number
return room
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simplify this using find:

Suggested change
@rooms.each do |room|
if room_number == room.room_number
return room
end
end
@rooms.find do |room|
room_number == room.room_number
end

Comment on lines +62 to +68
@rooms.each do |room|
room.reservations.each do |reservation|
if reservation.reservation_number == reservation_number
return reservation
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to have reservations stored in Room you should have this functionality inside of a method there instead of here:

Suggested change
@rooms.each do |room|
room.reservations.each do |reservation|
if reservation.reservation_number == reservation_number
return reservation
end
end
end
@rooms.each do |room|
room.find_reservation(reservation_number)
end

That properly encapsulates this functionality and means that Hotel has to know less about Room.

Comment on lines +113 to +130
count = 0
reservation_start = reservation.start_date
reservation_end = reservation.end_date
while start_date < end_date
while reservation_start < reservation_end
if start_date == reservation_start
count += 1
end
reservation_start = reservation_start + 1
end
reservation_start = reservation.start_date
start_date += 1
end
if (reservation.end_date - reservation.start_date == 1) && reservation_start == start_date
return false
else
return count < 2
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is very complex. Please comment the individual parts of something like this in the future.

Comment on lines +136 to +138
def is_between_two_dates(range_wanted, date)
return date >= range_wanted[0] && date <= range_wanted[1];
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This method would have been cleaner if it compared two DateRange objects. (Instead of a two element array of Date objects with a single date.)

Comment on lines +140 to +151
def next_reservation_number
max = 0
@rooms.each do |room|
room.reservations.each do |reservation|
if max < reservation.reservation_number
max = reservation.reservation_number
end

end
end
return max + 1
end
Copy link
Contributor

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 max:

Suggested change
def next_reservation_number
max = 0
@rooms.each do |room|
room.reservations.each do |reservation|
if max < reservation.reservation_number
max = reservation.reservation_number
end
end
end
return max + 1
end
def next_reservation_number
max = @rooms.max do |room|
room.reservations.max do |reservation|
reservation.reservation_number
end
end
return max + 1
end

check_dates(start_date, end_date)
@start_date = start_date
@end_date = end_date
@total_cost = ((@end_date - @start_date)) * 200
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra parens:

Suggested change
@total_cost = ((@end_date - @start_date)) * 200
@total_cost = (@end_date - @start_date) * 200


room = hotel.find_room(1)

res1 = HotelSystem::Reservation.new(1, Date.today, Date.new(2020,03,29))
Copy link
Contributor

Choose a reason for hiding this comment

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

This test will break after March 29th 2020:

Suggested change
res1 = HotelSystem::Reservation.new(1, Date.today, Date.new(2020,03,29))
res1 = HotelSystem::Reservation.new(1, Date.today, Date.today + 15)

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