Code Room
Code reviewMedium
Question
Review this Java endpoint that fetches a document and its collaborators.
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("/docs/{id}")public Map<String, Object> getDoc(@PathVariable String id) { Document doc = repo.findById(id).orElse(null); Map<String, Object> resp = new HashMap<>(); resp.put("id", doc.getId()); resp.put("title", doc.getTitle()); try { resp.put("collaborators", collabService.fetch(id)); } catch (Exception e) { // best effort } return resp;}Run or narrate your approach, then ask the coach.