Code Room
Code reviewMedium
Question
Review this Java Spring controller that fetches a user.
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
@GetMapping("/users/{id}")public ResponseEntity<Map<String,Object>> getUser(@PathVariable String id) { User u = repo.findById(id).orElse(null); Map<String,Object> body = new HashMap<>(); if (u == null) { body.put("error", "not found"); return ResponseEntity.ok(body); } body.put("id", u.getId()); body.put("name", u.getName()); return ResponseEntity.ok(body);}Run or narrate your approach, then ask the coach.