Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the MethodValidate method #4

Closed
4k1k0 opened this issue Jan 19, 2022 · 1 comment
Closed

Refactor the MethodValidate method #4

4k1k0 opened this issue Jan 19, 2022 · 1 comment

Comments

@4k1k0
Copy link
Contributor

4k1k0 commented Jan 19, 2022

Right now the MethodValidate method has a switch case with a lot of boolean logic and is difficult to read.

I propose using validation functions for each case. So instead of

case ccDigits.At(4) == 4011 || ccDigits.At(6) == 431274 || ccDigits.At(6) == 438935 ||
		ccDigits.At(6) == 451416 || ccDigits.At(6) == 457393 || ccDigits.At(4) == 4576 ||
		ccDigits.At(6) == 457631 || ccDigits.At(6) == 457632 || ccDigits.At(6) == 504175 ||
		ccDigits.At(6) == 627780 || ccDigits.At(6) == 636297 || ccDigits.At(6) == 636368 ||
		ccDigits.At(6) == 636369 || (ccDigits.At(6) >= 506699 && ccDigits.At(6) <= 506778) ||
		(ccDigits.At(6) >= 509000 && ccDigits.At(6) <= 509999) ||
		(ccDigits.At(6) >= 650031 && ccDigits.At(6) <= 650051) ||
		(ccDigits.At(6) >= 650035 && ccDigits.At(6) <= 650033) ||
		(ccDigits.At(6) >= 650405 && ccDigits.At(6) <= 650439) ||
		(ccDigits.At(6) >= 650485 && ccDigits.At(6) <= 650538) ||
		(ccDigits.At(6) >= 650541 && ccDigits.At(6) <= 650598) ||
		(ccDigits.At(6) >= 650700 && ccDigits.At(6) <= 650718) ||
		(ccDigits.At(6) >= 650720 && ccDigits.At(6) <= 650727) ||
		(ccDigits.At(6) >= 650901 && ccDigits.At(6) <= 650920) ||
		(ccDigits.At(6) >= 651652 && ccDigits.At(6) <= 651679) ||
		(ccDigits.At(6) >= 655000 && ccDigits.At(6) <= 655019) ||
		(ccDigits.At(6) >= 655021 && ccDigits.At(6) <= 655021):
		return Company{"elo", "Elo"}, nil

It could change to

case isElo(ccDigits):
    return Company{"elo", "Elo"}, nil
@4k1k0 4k1k0 mentioned this issue Jan 19, 2022
@4k1k0
Copy link
Contributor Author

4k1k0 commented Jan 19, 2022

Solved on #6

@4k1k0 4k1k0 closed this as completed Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant