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

Could we/should we replace the CardType as an enum to an object hierarchy? #5

Open
torendil opened this issue Sep 22, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@torendil
Copy link
Contributor

torendil commented Sep 22, 2021

Regarding the use of the library, keeping an enum such as CardTypes means that users will mostly have to use a huge switch to parse the type of card (for instance, in order to add some css class to display the card logo or in order other things, true story here).

Having an object hierarchy would allow for simpler overrides and usage, and keeping the object paradigm.

Your thoughts on that? I volunteer for this task if it is accepted

@thinkbeforecoding
Copy link
Member

thinkbeforecoding commented Sep 24, 2021

It seems the Enum values can be grouped in categories.. Visa/Maestro/Amex.

If the problem for the logo is to group them, it would be neat to define another enum for these categories, and have a function type -> category.. The switch on category would be shorter, and less prone to change.

The hierarchy would probably not help here, switching on it would be weird even with C# pattern matching. ( that would be more natural with DUs).

@aloisdg aloisdg added enhancement New feature or request question Further information is requested labels Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants