Welcome Guest, Not a member yet? Register   Sign In
Credit card helper
#1

[eluser]jmadsen[/eluser]
it's just a function to find the credit card name based on the card number.

there are a lot of them out there, but I found them to be buggy, no unit tests, too concerned with using clever techniques to be fast & reliable, or just plain ignored basic concepts like "Don't try every card under the sun before checking for Visa or Master Card "

I'm sure there's room for improvement, although I'm not so interested in shaving a few milliseconds by using a regex instead of a substr, or things like that.

https://github.com/jrmadsen67/credit_card_helper
#2

[eluser]Aken[/eluser]
Regex is slower than substr anyway Smile

I can tell you that you don't need to assign a variable when returning the matching card names. That variable loses scope anyway, so it's useless.

There are other changes I would make, but they're either personal preference or incredibly insignificant unless you're running this function thousands of times.

That Luhn check is actually what's crappy - maybe you should rewrite that one yourself! Smile
#3

[eluser]jmadsen[/eluser]
[quote author="Aken" date="1329724719"]
I can tell you that you don't need to assign a variable when returning the matching card names. That variable loses scope anyway, so it's useless.
[/quote]

yes, I think we all know that. It makes things a little clearer to read & easier to make adjustments later

[quote author="Aken" date="1329724719"]
There are other changes I would make, but they're either personal preference or incredibly insignificant unless you're running this function thousands of times.
[/quote]

then, uhm...so what?

[quote author="Aken" date="1329724719"]
That Luhn check is actually what's crappy - maybe you should rewrite that one yourself! Smile
[/quote]

really? care to actually explain the problems with it? I didn't want to write a Luhn Algorithm, I wanted to write a credit card name checker.

you just trying to get your post count up or something? what a waste of a post.
#4

[eluser]Aken[/eluser]
Yeah, just spamming for the hell of it :roll:

Let me clarify a couple of things. First, I can't automagically know the skill levels of every person on these forums. So if I see something that I think should be pointed out in the event that the person doesn't know a proper method, I'm going to do so. Hence why I mentioned the variable assignments on return. Frankly, I don't see how it's easier to read or make adjustments later, but if have future plans for it, maybe it's handy.

Also, when people share code, especially on Github, I see that as an invitation for comments and critique. That's why I mentioned other changes that I didn't think were important enough. I didn't feel like going through and nitpicking every little thing I would do differently, even though I've been having fun benchmarking random changes for the last couple hours. I think that would be even more douchey than what I said. Perhaps I could've been more specific with the meaning of my statement, which should translate into something like "I'd do things a bit differently, but nice job so far."

Lastly, I know that you did not create the Luhn check - I saw the copyright for it. That was my own little shot at whoever wrote that code. I said you should rewrite it so it and your own function might perform better (if your function is fast but that one is slow, your function will be slow).

I'm not talking down to you or anything, so chill. You share code, you get feedback. If you actually want to see what I'd do differently, I will still fork it.
#5

[eluser]jmadsen[/eluser]
yes, I am in a grumpy mood, but:

"feedback" is not "this is shit - you should fix it"

you have a link to my github repo. you know how to fork. you know how to describe code, and why some is better than others.

real feedback is welcome, and was asked for. perhaps a little more effort in your comments in the future
#6

[eluser]Aken[/eluser]
I never said your code was shit, and I never said you should fix it. Stop putting words in my mouth. I'm trying to give you a freaking compliment.

I gave you the one piece of real feedback that I felt was necessary. The rest was personal style and nitpicking, so I didn't find it necessary. I'm sorry I didn't include a note about how your code was good as it was, because apparently that caused my entire post to be regarded as negative.

Still, though - you post code in public, you're going to get feedback of ALL kinds. Some of it is going to be stupid and pointless. Try to handle it a little better in the future, because I couldn't give a shit about your code anymore.




Theme © iAndrew 2016 - Forum software by © MyBB