Code Room
Code reviewMediumcr-g069
Subject Missing cacheLevel Mid–Senior~25 minCommon in Code quality & review interviewsIndustries Software development, Technology

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.

Talk through your review
Code to reviewjava
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.