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

Would it be useful to prefilter per cards? #32

Closed
aloisdg opened this issue Oct 15, 2021 · 3 comments
Closed

Would it be useful to prefilter per cards? #32

aloisdg opened this issue Oct 15, 2021 · 3 comments
Labels
enhancement New feature or request performance question Further information is requested wontfix This will not be worked on

Comments

@aloisdg
Copy link
Member

aloisdg commented Oct 15, 2021

Hi!

Let's look at the main example from the readme.

var card = Dedge.Cardidy.Identify("4127540509730813").Single();
Console.WriteLine(card); // print Visa

Let's say that as a dev, we would like to know if a given card is a Visa. The current code would be a good enough way. To work Identify() has to walk every card until the find a matching one.

Basically here is how Cardidy currently works:

var list = new [] { Amex, MC, Mir, Foo, Bar, Visa }

var results = list.Where(card => card is matching)
return results;

We could improve that by passing a prefiltered list to Indentify().

var card = Dedge.Cardidy.Identify("4127540509730813", where: new[]{Visa}).Single();
Console.WriteLine(card); // print Visa

and inside we would do:

var list = prefiltered == null || !prefiltered.Any() ?  new [] { Amex, MC, Mir, Foo, Bar, Visa } : prefiltered;
var results = prefiltered.Where(card => card is matching);
return results;

Yay or nay? Since there is not a lot of card I am not sure that we gain much by doing that.

@aloisdg aloisdg added question Further information is requested performance enhancement New feature or request labels Oct 15, 2021
@hey24sheep
Copy link
Contributor

That is a good "user defined filter" if a user/client needs to make a check for a particular card only and don't want to run "card check" against "all cards list".

In any case your complexity will always be O(n).

@aloisdg
Copy link
Member Author

aloisdg commented Oct 21, 2021

True. I am not sure if it is really worth it. We have currently 28 cards and most of them doesn't have much ranges to be tested...

@aloisdg
Copy link
Member Author

aloisdg commented Oct 27, 2021

I will close this one for now.

@aloisdg aloisdg closed this as completed Oct 27, 2021
@aloisdg aloisdg added the wontfix This will not be worked on label Oct 27, 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 performance question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants