Skip to content

Conversation

@mulhoo
Copy link

@mulhoo mulhoo 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? The hardest part was getting everything to connect properly, as well as figuring out how to navigate the various layers. I had a hard time grasping classes and building them on my own, so this project was hard for me with needing to completely build my own and not having pre-written tests there to guide me if I got it or not. Getting my room assignment code to all connect properly is something I am still working on. The individual pieces work how they should, but the unit doesn't quite work yet, so expect updates!!
What was a design decision you made that changed over time over the project? The biggest addition was adding in the calendar_date class to manage each day's reservations. Originally I was going to have calendar do everything, but that ended up being very complicated so I created another class to manage the individual dates.
What was a concept you gained clarity on, or a learning that you'd like to share? I feel like my understand of classes and their relationship to one another as a whole improved a lot, but I still need to work on doing my tests first rather than my code.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? Ensuring that the calculated cost of the reservation is correct.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? Haven't explicitly written the test yet since I've been so focused on getting the room assignment to work, but throwing up an error when the date isn't inputted properly, or is completely invalid. I also plan to write one for if the room number is negative for whatever reason as well as a few others in other places.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? The pseudocode was really helpful, as I had a very clear picture and plan for what I wanted to do and how I wanted everything to work. It definitely helped a lot to keep me organized, especially now that I am struggling to find where my code is not working 100% properly when it comes to assigning rooms to reservations.

@dHelmgren
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 (lots of code w/o tests)
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)) (Looks like this is being handled entirely by the calendar right now)
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
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

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 approached the challenge of design with a unique plan. It's challenging to build a design from the ground up, especially when there are such complicated needs embedded in the problem.

I do see some room for improvement around getting guidance earlier and improving you comfort with writing tests. Your ruby code is generally well organized into methods and very readable, but it's clear to me that at some point the project got a little bit away from you. In situations like that (they happen in industry too), the best thing to do is sit down with someone who is more experienced and say as much. Whomever they are can help you prune problem code and get you back on the rails. Second, I see a couple of syntactic slips here and there inside and outside your tests that are causing problems. By focusing on doing Red Green Refactor, you can get a lot clearer picture of how and when things went wrong before problems really start to pile up. An important part of this is making sure your tests fail before you expect them to pass.

Code Style Bonus Awards

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

Quality Yes?
Descriptive/Readable

t.libs = ["lib"]
t.warning = true
t.test_files = FileList['test/*_test.rb']
t.test_files = FileList['test/*_spec.rb']

Choose a reason for hiding this comment

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

Rails will soon start enforcing _test as the file ending, so it's better to start conforming your file names to what's in the Rakefile.

available_rooms_all_dates = []


if (reservation.total_nights == 1) && (@date_store[(reservation.start_date).iso8601].all_available_rooms.length == 20)

Choose a reason for hiding this comment

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

what is iso8601? Is this necessary?


(reservation.total_nights).times do |i|
if @date_store[(reservation.start_date + i).iso8601].nil?
date = CalendarDate.new

Choose a reason for hiding this comment

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

You make a new CalendarDate but your date variable doesn't leave the if block. What was your goal here?

end


date_range.each do |i|

Choose a reason for hiding this comment

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

What you want here is each_index. By default .each looks at the elements themselves.



def is_available?(room_number, date)
date = Date.parse(date).iso8601

Choose a reason for hiding this comment

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

Not sure why you're doing parse here. You can build the software to enforce that idea that the date is already parsed when it was given to you.

When something feels like more work than it ought to be, that's a good time to ask questions! Asking lots of questions about the scope of a project will serve you well at Ada and beyond!


it "has an array that keeps track of the available rooms" do

hopefully_an_array = @date_store[Date.parse("2020/05/04").iso8601].all_available_rooms

Choose a reason for hiding this comment

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

I think you meant to write this:

Suggested change
hopefully_an_array = @date_store[Date.parse("2020/05/04").iso8601].all_available_rooms
hopefully_an_array = @calendar.date_store[Date.parse("2020/05/04").iso8601].all_available_rooms


hopefully_an_array = @date_store[Date.parse("2020/05/04").iso8601].all_available_rooms

expect hopefully_an_array.must_be_instance_of Array

Choose a reason for hiding this comment

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

Be sure to use parens with expect, in situations like this it might not do what you think it's doing.

Suggested change
expect hopefully_an_array.must_be_instance_of Array
expect(hopefully_an_array).must_be_instance_of Array

id = reservation1[:id]
cost = @calendar.total_cost_reservation(id)

expect (reservation1[:cost]).must_equal cost

Choose a reason for hiding this comment

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

Putting a space here means expect is called without arguments, which will cause your tests to misbehave.

Suggested change
expect (reservation1[:cost]).must_equal cost
expect(reservation1[:cost]).must_equal cost

end

it "returns true/false if given room is available on a given date" do
yesorno = @calendar.is_available?(5, "2020/05/07")

Choose a reason for hiding this comment

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

Snake case!

Suggested change
yesorno = @calendar.is_available?(5, "2020/05/07")
yes_or_no = @calendar.is_available?(5, "2020/05/07")

Comment on lines +31 to +34
reservation1 = @reservation1.details
expected_outcome = [reservation1]
actual_outcome = @calendar.reservations_on_date("2020/05/04")
assert_equal(actual_outcome, expected_outcome)

Choose a reason for hiding this comment

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

With a test case of only one, this test is a little inconclusive.

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