Code Room
Vibe codingHard
Question
An AI agent wrote this Java service method to create an order, charge the card, and send a confirmation email — all wrapped in one transaction for 'consistency'. Under load, the team sees database connection-pool exhaustion and occasional orders with no payment.
@Transactionalpublic Order placeOrder(Cart cart) { Order order = orderRepo.save(new Order(cart)); PaymentResult pr = paymentGateway.charge(cart.total()); // external HTTP, ~800ms order.setPaymentId(pr.getId()); emailService.sendConfirmation(order); // external HTTP, ~400ms return orderRepo.save(order);}What's wrong with the transaction boundary, and how should this be structured?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.