Code Room
Code reviewMedium
Question
Review this Java service method called on every request.
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
public BigDecimal convert(BigDecimal amount, String from, String to) { List<Rate> rates = rateRepository.findAll(); // ~5000 rows, rarely changes BigDecimal fromRate = rates.stream() .filter(r -> r.getCurrency().equals(from)).findFirst().get().getValue(); BigDecimal toRate = rates.stream() .filter(r -> r.getCurrency().equals(to)).findFirst().get().getValue(); return amount.multiply(toRate).divide(fromRate, 8, RoundingMode.HALF_UP);}Run or narrate your approach, then ask the coach.