#306 Code Review of a Currency Conversion Service

Companies:
Unknown company
Themes:
SpringTransactionsCode Review

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

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in