ballerina-guides / gcp-microservices-demo

Ballerina Implementation of GCP Online Boutique Sample
Apache License 2.0
15 stars 38 forks source link

Bad method names in Ballerina classes #42

Closed sameerajayasoma closed 1 year ago

sameerajayasoma commented 1 year ago

See this code snippet: https://github.com/ballerina-guides/gcp-microservices-demo/blob/main/payment/payment_service.bal#L37

        CreditCardInfo creditCard = value.credit_card;
        CardValidator cardValidator = new (creditCard.credit_card_number, creditCard.credit_card_expiration_year,
            creditCard.credit_card_expiration_month);
        CardCompany|error cardValid = cardValidator.isValid();
        if cardValid is CardValidationError {
            log:printError("Credit card is not valid", 'error = cardValid);
            return cardValid;
        } else if cardValid is error {
            log:printError("Error occured while validating the credit card", 'error = cardValid);
            return cardValid;
        }

The following isValid() method returns CardCompany|error. It should be renamed to something like getCardDetails(). CardCompany|error cardValid = cardValidator.isValid();

Btw, the usage of a class does not make sense here.