In this exercise, you'll be presented the code that tries to book total of 10 rooms from different guests. The goal is to make the code work as intended. Also suggest areas of improvement and show us the improvements in the code.
- This is designed to be completed in 2 hours. Our suggestion is not to spend too much time on this challenge.
- It is an open book exercise. You can use any tools and websites the way you would use in a real work environment.
- The code has to be compiled and run for each section, so that we can evaluate the output.
- If there is any part that is not clear to you, make a reasonable assumption, and state it in comment. Adjust code accordingly.
- The code has to run and finish gracefully no matter what.
- Make the output meaningful, and formatted in a way that is easy to read.
- Java 21
- Maven 3.8 or higher
- IntelliJ IDEA or any other IDE of your choice
- Main - the application's main class.
- Room - represents a hotel room type and its availability
- RoomDatabaseAccessService - provides db access to room data
- BookingRequest - contains a request to book a room
When the application starts, it will initialize rooms and their availability. It will then create a list of booking requests and try to book the rooms. The goal is to process multiple requests simultaneously, while ensuring that the rooms are booked correctly.
In this challenge, just do not make it "work", meaning it outputs something appears to be working. Instead, imagine that you are building a real website, where you have tens of thousands of users are trying to book rooms, while the system needs to maintain integrity. Demonstrate your ability to write code that would work in such a large, real-world system.
Make the app output your name to stderr and the answer to the work-from-office question to stdout. Read the code comment for details, and follow the instructions.
Read the code, and based on the concept above, test and see if it works as intended. State what is the problem in std output, and fix it.
Given that code, and thinking in that this is a real website, what would you do to make it more performant?
There may be cases where the code works on the surface, but it is not correct and cause issues when handling with more data, more threads, more requests, etc. Find such potential issues and fix them.
Find classes that can be immutable. Discuss if that's a good idea or not, and if so, implement it. If not, explain why.
Write a thorough unit test to test for the RoomDatabaseAccessService class.