I am developing a website for vacation home rentals, and I would like some help with the design of the object model.
I have the houses model, the users model, and now I am going to design and build the reservations model, which would have start and end date fields, user field, and a house field.
The booking process has several actions involved, choosing the house, choosing the dates, and finally making the payment. How would I develop the booking process so the reservation isn’t saved until all these actions have been done? Is it a would idea to create a different model (ReservationRequest, for example) to handle the two states of the reservation? Otherwise, how can I handle the two states of a reservation?
Sorry if it this is a vague question, but any guidance for this kind of process will be very useful to me.
It depends on your policy. I wouldn’t store anything server-side until a valid payment is initiated. This way users can’t block houses and then change their minds. I’d pass objects (houses and dates) back and forth between different pages of the wizard. When a payment is initiated I’d store the Reservation in the database – so assuming an optimistic point of view – and this would lock the House. If then the payment fails, destroy the Reservation and send appropriate messages (emails). This way everyone can restart the whole process. But this really depends on how many users there will be and how concurrent is the environment