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

Sara - Branches #36

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

Sara - Branches #36

wants to merge 16 commits into from

Conversation

sarashahbaig
Copy link

Hotel

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What was a design challenge that you encountered on this project? One of the design challenges that I encountered was figuring out how many classes I need to represent the objects that make up the hotel system. I was not sure what to track for the hotel system and what not to. For instance, I initially came up with multiple classes but then had to narrow it down. I ended up having a customer and room class just to be able to better track reservations.
What was a design decision you made that changed over time over the project? As mentioned above, one of the design decisions that I changed over time was to decrease the number of classes that would make up the hotel system. Finally, I decided to use a customer and room class to keep track of the reservations.
What was a concept you gained clarity on, or a learning that you'd like to share? This assignment helped me better understand how to test code for every step of program. Writing more tests gave me a better understanding of how to think about where my code would break and what things I need to take into consideration.
What is an example of a nominal test that you wrote for this assignment? What makes it a nominal case? An example of a nominal test that I wrote was to make a simple hotel object given its id and name and then check if the attributes data types are the ones that I had defined in the class. Another test was to check the number of rooms that had been predefined.
What is an example of an edge case test that you wrote for this assignment? What makes it an edge case? And example of edge case test that wrote was to check if the date range given is a valid date range. An edge case is one that tests the extremes of our program.
How do you feel you did in writing pseudocode first, then writing the tests and then the code? I think I did a good job in following the steps of writing pseudocode first, then the tests and then the code. It made met solve the problems I faced writing this program easier to solve.

@tildeee
Copy link

tildeee commented Sep 15, 2019

Hotel

What We're Looking For

Test Inspection

Workflow yes / yes but no test / no
Wave 1
List rooms x
Reserve a room for a given date range yes
Reserve a room (edge case) edge cases get implemented and tested in the reserve_room_on method
List reservations for a given date yes, no tests on edge cases
Calculate reservation price yes
Invalid date range produces an error yes, though tests only one case (end date before start date). What about end date on same day as start date?
Test coverage yes
Wave 2
View available rooms for a given date range implemented and with tests, but the tests and implementation are wrong
Reserving a room that is not available produces an error yes, but this is confusing. Why is this implemented in reserve_room_on and not make_reservation? What's the difference between the two methods?
Test coverage the tests don't cover edge cases thoroughly, aren't organized in describe blocks well, and they cover parts of the nominal cases
Wave 3
Create a block of rooms no
Check if a block has rooms no
Reserve a room from a block no
Test coverage no

Code Review

Baseline Feedback
Used git regularly I expect more detailed commit messages such as what kinds of changes you made for reservations. Usually messages are like "implements reserving rooms for valid dates" or "implements checking dates that they are valid" or "adds helper method to parse dates"
Answer comprehension questions x
Design
Each class is responsible for a single piece of the program Some classes are not used. Many methods are not responsible for a single piece of functionality.
Classes are loosely coupled All of the functionality is in the Hotel class, such as checking for valid dates or calculating the cost
Fundamentals
Names variables, classes and modules appropriately You have some typos in method names. Also, you have a Duration class and a DateRange class-- why do both exist? Your method names are also ambiguous. Your tests are not organized into describe and it blocks well, and aren't named accurately
Understanding of variable scope - local vs instance largely, yes
Can create complex logical structures utilizing variables There's a lot of duplication around dates and availability. Do you use the Date class or the Duration class? It is not consistent. How do you find availability? It is not consistent, because there isn't clarity on how to keep track of availability.
Appropriately uses methods to break down tasks into smaller simpler tasks Yes! You did this well :)
Understands the differences between class and instance methods yes
Appropriately uses iterators and Enumerable methods yes, great job!
Appropriately writes and utilizes classes Feel free to clean up your unused files and unused classes before submission. You wrote a lot of classes and instance methods inside of the classes that never get used, like Duration's overlap? method
Appropriately utilizes modules as a namespace yes
Wrap Up
There is a refactors.txt file yes
The file provides a roadmap to future changes There isn't a list of concrete changes you'd like to make besides more tests; during break week, I encourage you to take time and think about how to clean up your Hotel design! (We have break week homework for this)

Overall 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!

Overall, you did a great job of putting into action a lot of our coding practices; You have a lot of good work around making large classes that rely on each other. You used composition correctly! You use instance variables and instance methods correctly! You used find, find_all, and a lot of other Enumerable methods well. I have a lot of confidence that your fundamentals in programming are exactly where we want them to be.

However, I think I see some discomfort around organizing code, and seeing how it all connects. It feels like you were trying to organize too much at the same time, and there's lack of clarity around how your tests and how your methods are organized. For example, tests were sometimes in the wrong area of the file! Other times, methods that were named one thing were doing something else. Another example is that sometimes you wrote a method in Class A that did Functionality A, and then you wrote a method in Class B that did the same functionality!

I'm leaving a lot of comments with questions to ask yourself that will help you organize your code. When you have well-organized code, then you can start to target your code and your time better. :)

You didn't install SimpleCov as part of the project directions :( With SimpleCov, you would see that you have 90.24% test coverage (as opposed to the required 95% test coverage). Don't forget our SimpleCov lesson, and let me know if you have any questions because we'll be using SimpleCov in the future.

Lastly, there are a lot of files that are in your project submission that don't get used. I encourage you to delete those as soon as you realize you don't need them. The less files you have, the easier it is to keep track of your code. :)

One more overall thought: We went through in class that we would not have a main.rb file for this project, and the designs I looked over on the first day of the project did not have a Customer class, and we talked about how Customer should not be a class because there were no requirements about it.

I'd love to know how you missed this information so we can make sure you get the same design information and hints as everyone else in class.

Overall, from your hotel project, I have full confidence that you have fundamental programming skills! I also see that we should spend time to make sure that you think of code organization and relationships between different pieces of code correctly. If we don't feel a little more comfortable about our file system and tests, it may give us challenges later.

# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
Copy link

Choose a reason for hiding this comment

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

Hm, why did you delete the contents of this file?

attr_reader :start_date, :end_date

def initialize(start_date:, end_date:)
@start_date = convert_to_date(start_date)
Copy link

Choose a reason for hiding this comment

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

Could we use Date.parse(start_date) instead of using the convert_to_date method?

end
end

def convert_to_date(date_str)
Copy link

Choose a reason for hiding this comment

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

This method doesn't get tested!

return night_count
end

def overlap?(duration)
Copy link

Choose a reason for hiding this comment

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

This method never gets tested OR used in any other file. Can we delete it, or can we refactor our code to use it?

# require_relative 'reservation'

# one_reservation = Reservation.new(id:1, customer_id:2, room:303, duration:3, total_cost:300)
# date_range = DateRange.new(id:, start_day:, end_day:)
Copy link

Choose a reason for hiding this comment

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

Feel free to delete this file before project submission

end

#list of rooms that are not reserverd
def get_availbale_rooms(date)
Copy link

Choose a reason for hiding this comment

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

"available" is mispelled in your method name-- watch out!

def get_availbale_rooms(date)
available_rooms = @rooms.find_all { |room| room.availability == true }
# rooms_date_range = available_rooms.find_all { |room| (date >= room.reservation.duration.start_date && date <= room.reservation.duration.end_date) }
return available_rooms
Copy link

Choose a reason for hiding this comment

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

This method doesn't use the date parameter. Why not? What does it mean for a room to have availability? Isn't the requirement to find rooms that are available for a specific date? What does it mean when a room is "available"?

return total_cost
end

def reserve_room_on(cust_id, room_number, start_date, end_date)
Copy link

Choose a reason for hiding this comment

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

What is the difference between reserve_room_on and make_reservation? How can we change the name of these methods so that they are more clear about what they do and what the differences are?

def reserve_room_on(cust_id, room_number, start_date, end_date)
room = @rooms.find { |room| room.number == room_number }
if room.availability == false || room.reservation != nil
raise ArgumentError.new "This room is already reserved"
Copy link

Choose a reason for hiding this comment

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

Minor suggestion: Instead of an ArgumentError, could we raise a more specific kind of error, or create a new custom Error class?

end
end

HotelBooking.main
Copy link

Choose a reason for hiding this comment

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

Feel free to delete this file before project submission

@id = id
@number = number
@cost = cost,
@availability = availability,
Copy link

Choose a reason for hiding this comment

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

Why are there commas here and the line above? Also, watch your indentation!

@reservation = reservation
end

def total_cost()
Copy link

Choose a reason for hiding this comment

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

This method isn't implemented or used anywhere else, so feel free to delete this method

@name = name
end
end
end
Copy link

Choose a reason for hiding this comment

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

No tests! Maybe this is a result of realizing that our project doesn't require Customers being implemented, so it was hard to understand what to test a Customer to do :)

}.must_raise ArgumentError
end
end
describe "" do
Copy link

Choose a reason for hiding this comment

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

Don't forget to add a description to your describe blocks. If you can't find a good name, then maybe you need to think about how you're organizing your code

end
end

describe "add_customer" do
Copy link

Choose a reason for hiding this comment

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

Hm, did we have a requirement to make sure that we could add a customer?

end

describe "add_customer" do
it "checks the number of customers before and after" do
Copy link

Choose a reason for hiding this comment

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

Good test though!

before do
@reservation_list = @hotel.reservations
end
it "reservation should be a list" do
Copy link

Choose a reason for hiding this comment

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

Maybe a more accurate sentence is "reservation_list starts as an empty array"

end
end

it "get the total cost for a given reservation" do
Copy link

Choose a reason for hiding this comment

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

This test isn't in a describe block that is accurate-- it's in the describe block named "test list of reservations". Could we make a different describe block with a name that is more accurate, and put this test inside there? Or could we rename the current describe block so it's more accurate?

cust_id = @customer.id
@hotel.make_reservation(cust_id, "2019-09-01", "2019-09-05")
available_rooms = @hotel.get_availbale_rooms(date)
expect(available_rooms.length).must_equal 19
Copy link

Choose a reason for hiding this comment

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

What happens if you make a reservation for "2999-01-01" to "2999-01-05"? Your available_rooms.length for available rooms on date (2019-09-02) is 18, not 19. Your implementation doesn't use date, and your tests don't check for this case!

end
it "reserve an already reserve room" do
cust_id = @customer.id
@hotel.make_reservation(cust_id, "2019-09-01", "2019-09-05")
Copy link

Choose a reason for hiding this comment

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

Why do we use make_reservation and reserve_room_on? Is there a way that our code could be refactored so only one of these methods exists?

duration: @duration)
end

describe "cost" do
Copy link

Choose a reason for hiding this comment

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

You can put multiple it blocks in one describe block. Right now, you have two describe blocks that are both named "cost"... instead, consider moving the it blocks under the same describe block.

def total_cost()
end
end
end
Copy link

Choose a reason for hiding this comment

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

You have no tests for Room :(

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