Cardidy icon indicating copy to clipboard operation
Cardidy copied to clipboard

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

Open torendil opened this issue 4 years ago • 1 comments

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

torendil avatar Sep 22 '21 14:09 torendil

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).

thinkbeforecoding avatar Sep 24 '21 07:09 thinkbeforecoding