Spring Boot question

I have a two part question that is slightly related. What is the best way to work with method params Using IDS bookRoom(Long customerID, Long roomID, LocalDateTime checkIn, LocalDateTime checkOut) or Using Object references bookRoom(Customer customer, Room room, LocalDateTime checkIn, LocalDateTime checkOut) Also I have Customer, Room, Booking Reservation If a object (BookingReservation ) can only exist if there is a Customer or Room is that equivalent of saying Customer and Room have their own independent lifecycle because you can create or a user can create an account, an admin can create a room but for BookingReservation doesn't have it's own lifecylce because to make it you need Customer and Room together with it. Am I correct in saying that during any activity in UI will trigger a Controller behaviour but you must have a method in the controller with bookRoom paramaters Reservation alongside CustomerID and RoomID as Reservation can't be created alone so in that very method the combination of Customer, Room will be passed in the constuctor or service method of Reservation within the inner body of bookRoom method
6 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @b2aDev! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Madjosz
Madjosz3mo ago
APIs should work with IDs. Functions should work with objects.
ayylmao123xdd
ayylmao123xdd3mo ago
about the second question you first create the room and customer so admin creates a room user makes an account user creates a reservation idk if thats what you meant to explain
b2aDev
b2aDevOP3mo ago
@Madjosz | codewars.com @ayylmao123xdd you both made good points
ayylmao123xdd
ayylmao123xdd3mo ago
so if you are making a database the reservation should have a relation to room and client and they shouldnt be null at least for the most popular use case so to create a reservation the frontend should send room id client id date from date to and then in your application you create the reservation if the room will not be occupied
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?