Code Room
Code reviewHard
Question
Review this Java booking method that charges the customer, then persists the reservation.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
@Transactionalpublic Booking book(BookingReq req) { Charge c = paymentGateway.charge(req.getCardToken(), req.getAmount()); // external API Booking b = new Booking(req, c.getId()); bookingRepo.save(b); // may throw on constraint violation inventory.decrement(req.getRoomId()); // local DB return b;}Run or narrate your approach, then ask the coach.