#306 Code Review of a Currency Conversion Service
Perform a code review:
@Component
public class Converter {
public ConversionService cs;
public NotificationService ns;
public AccountRepository ar;
public Converter(ConversionService cs,
NotificationService ns,
AccountRepository ar) {
this.cs = cs;
this.ns = ns;
this.ar = ar;
}
@Transactional
public void convert(double sumInRub,
String currencyCode,
String accountNumberRub,
String accountNumber) {
double rate = cs.getRate("RUB", currencyCode);
Double convertedSum = sumInRub * rate;
ar.decrease(accountNumberRub, sumInRub);
ar.increase(accountNumber, convertedSum);
ns.send("Conversion successful");
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor