Build a corporate hotel booking engine. This engine has to satisfy the needs of 3 different types of actors:
To achieve that, the engine needs to provide 4 main services that work in close collaboration with each other.
The four services are described below. The <?>
indicates you can use whatever primitive or type you want.
Used by the hotel manager to define the types and number of rooms of each type the hotel has. It also can return hotel information given a hotel ID.
public class HotelService {
// Collaborators(?)
void addHotel(<?> hotelId, <?> hotelName);
void setRoom(<?> hotelId, <?> number, <?> roomType);
<?> findHotelBy(<?> hotelId);
}
Rules
The addHotel(...)
method should throw an exception when the hotel ID already exists or create the hotel otherwise.
The setRoom(...)
method should throw an exception if the hotel does not exist. It should insert or update a room
according to its room number.
The findHotelBy(<?> hotelId)
should return all the information about the number of rooms for the specified ID.
Enables company admins to add and delete employees.
public class CompanyService {
// Collaborators(?)
void addEmployee(<?> companyId, <?> employeeId);
void deleteEmployee(<?> employeeId);
}
Rules
Allows company admins to create booking policies for their company and employees. Booking policies determine if an employee booking request is allowed by their company. There are two types of booking policy:
public class BookingPolicyService {
// Collaborators(?)
void setCompanyPolicy(<?> companyId, <?> roomTypes);
void setEmployeePolicy(<?> employeeId, <?> roomTypes);
boolean isBookingAllowed(<?> employeeId, <?> roomType);
}
Business Rules
Technical Rules
setCompanyPolicy(...)
and setEmployeePolicy(...)
should create a new policy or update an existing
one. No duplicate company or employee policies are allowed.isBookingAllowed(...)
should take into account the employee and the company the employee works for.Allows employees to book rooms at hotels.
public class BookingService {
// Collaborators (?)
Booking book(<?> employeeId, <?> hotelId, <?> roomType, Date checkIn, Date checkOut);
}
Rules
<?>
can be replaced with whichever type or primitive you prefer.Bellow are a few variations of this kata that you can mix and match.
1. Defined Services, Undefined interfaces In this variation you still need to use the 4 services defined above, but are totally free to create whichever methods you like in each one of the services.
2. Undefined initial design (Advanced) In this variation, all the business requirements for the 3 different of actors remain the same, but you are free to design the way you like. No need to stick to the 3 services.
3. Hotel booking policies In the original requirements, only room type is taken into account. In this variation, we can also assign which hotels are allowed by each company or for each employee. E.g. A company may allow bookings for standard rooms and junior suites for hotel "1" and but only allow standard room for hotel "2". Same for employee policies.
4. Over booking policy Some hotels may allow a small percentage of overbooking. E.g. 5% or 10%.
5. Strict component boundaries In this variation, each service represents the public interface of a business component. All the internals should not be accessible by any other service. Components can only interact via their public interface. E.g. Service A can talk to Service B, but not with Repository B.
6. Sequence Diagram Only In this variation, you don't need to write any test or code. You should only create a sequence diagram at code level (collaborators, methods, parameters, return types, data structures, etc) representing the detailed solution. The sequence diagram should represent the interaction of the 3 actors with the services and the internals of each service, including their collaboration with other services and internal collaborators.