- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This is actually not a WTF. They are obviously using ProbeilitySpring, one of those frameworks that gives you tons and tons of implicit... well implicit everything. When evaluating what appears to be the same variable twice, the second evaluation actually runs against something entirely different. My guess is that they are checking something sensitive like SSN, and wanted to mask that in the code, you know as a security thing.
Admin
Go on, enlighten us then, genius.
Admin
Ah, you ignorant people. Clearly "probeility" is a technical term referring to a measure of the extent to which an object can be probed.
Admin
Maybe srvReqeust does a database access. If they can successfully read the database twice in a row, this is clearly grounds for celebration and awarding a higher score. If that fails we see if it will at least work once.
Admin
And that's TRWTF because I know for a fact that in my ZIP code there is actually a 20% chance that someone who shares my last name is me.
/CAPTCHA "nibh": Mrs. Frisby got lost
Admin
Super-hyper-optimized:
..since I assume probeility is a value between 1 and 100, and dividing an int by an int results in (surprise!) a DIV. XD
Admin
From a mathematical point of view, shouldn't that be "a sensible range of 0 to 1?
Admin
I finally got what it is supposed to do. If two entries match in all fields that are available, then this function is supposed to calculate the probability that they are the same person. That would be based on how many fields are available to match.
Except of course they did not even get the function signature right, because you need to know both records that are being matched. If the seemingly matching record has a field that the record you are searching for does not, then that does not increase the probability of a match.
Admin
Admin
No, that´s why there is a thing like dependency injection.
Admin
Your aim is off.
Admin
Is it GCS or GES? Maybe these are two separate projects, and they had to use the same weighing algorithm for both. When they were separated, the projects used something else for weighing, but when they were merged, the projects only needed getLastName() to be null, so instead of going in and changing the code, they just did a search and replace. Hence, the WTF with all the last namaes.
Admin
Well played, sir.
CAPTCHA: jugis - Al Bundy and I just sent in our subscription cards!
Admin
pi is exactly 3!
Admin
Actually, this is a very genius and brillant security solution: this function is in such a position in the code, that on the company's specific architecture the instruction pointer will overflow exactly before reaching the ominous "minScore = 2;" part. So the processor will load the instruction from the specifically prepared part of memory (actually the top left pixel of the image of the company logo) which consists in a jump instrucion to exacty the position of the "return". So even if someone steals the code, no one else will ever be able to use this brillant part of carefully selected and scientifically tested probability calculation. And this feature will never be documented, just to make sure no one will be able to steal it.
Admin
This is amazing, the amount of WTF's is crazy. I would presume this is a methed in the MemberRequest class, so that you would run it as:
Which leads me to my favourite WTF: the weight is based on weather the db entries of othermr exist or not, instead of if they match thismr. So whichever customer has the greatest amount of info, would always get the highest rating.
2nd best WTF: is prolly that minScore is declared as int instead of float;
3rd is: "minScore = (float) (minScore + 6.1);" which should be "minScore += 6.1F", or "minScore += (int)6.1F" considering minScore is an int.
4th: "probeility", wtf is that?
5th: "if (srvRequest.getLastName() != null && srvRequest.getLastName() != null)" "else if (srvRequest.getLastName() != null)" LOL, funny thing is, when refactoring code of mine once, i found "if ((bla == true) && (bla == true))" and thought to myself "what drugs was i on when i wrote this".
6th: minScore = 2; I presume that was put in from testing with an empty db, and forgot about.
7th: "return minScore * probeility / 100;" These are all ints, lol.
8th: the arbitrary weight number each of the values get, I'd prolly give phone number a bit more weight, since ppl prolly wouldnt have the same ph number unless same household.
9th: why does checking for last name rely on zipcode?
Admin
Huh. No wonder this is a WTF. It looks like it's missing some important comparisons.
CAPTCHA: commoveo -- I will pay in beero
Admin
I disagree. It is quite easy to create a language in which it is absolutely impossible to write bad programs.
Of course, such a language would make it impossible to write good programs, but that's not part of the spec.
Admin
This version is probeily the best because multiplication is faster than division.
Admin
So does anybody know what language this would actually compile in? It won't compile without throwing errors in java or C# apparently.
Admin
Admin
Java should throw an error on the int = (float) cast unless there's some flag you can set to ignore that.
Admin
I recently ran across some code I wrote that did exactly this double test for null. I have no idea how I managed to generate such stupidity, but fortunately the code still worked after I took out the second check. Or maybe it was the first...
Admin
A lack of understanding on the basics of good software engineering practices does not constitute a valid opinion. Having an opinion does not necessarily makes it a valid one.
For every single piece of atrocious code I've run into, there has been losses in the tens of thousands, if not hundreds of thousands of dollars associated to each of them.
And for each of those code turds, there has been a a human code generator (calling him programmer denigrates the profession) who was of the opinion those turds were actually a-okay and not really a WTF.
Leaving poorly written debugging code in live code is a WTF.
Writing poorly written debugging code is also a WTF.
Writing poorly written code is a WTF no matter what.
And, barring language barriers, having misspelled words or variable names in poorly written code (not spelling errors on otherwise workable code, but on piss-poor, retardocalyptically badly written code) usually shows that the original developer either didn't give a rat's ass about quality (or the employer who was paying him his salary) or was completely clueless and overwhelmed and should be kept away from source code in the name of anything that is holy.
Your opinion will take you places... probeibley. I'll give you one piece of gratuitous advice and take it for what it is:
Instead of sarcastically going "excuse me for having a different opinion", spend some time in understanding what constitutes good principles of programming and why this particular piece of code is a true WTF.
Admin
Probeily.
Admin
It compiles fine in C++ if you preface it with:
Admin
I think I've gotten code from these consultants... love the three "lastname != null" clauses - all identical as far as I can tell.
Admin
Admin
The more CodeSODs I read on this site, the more convinced I am that I'd pass for a upper-level Jr developer. (i.e. I have a lot to learn, but sheesh, I can do a lot better than this tripe!)
Admin
Hello, my company wrote this cod. It is protected by copywrite and we must demand that you do not share the special heuristic numbres with the Internet like this. We spend $1 MILLION EACH YEAR protecting our world leading reseach. Also you have put a typo in and it should be checking
and after that fix it all work perfectly. You code snobs make me sick.Admin
That's what you get for hiring people who have no special skills except for demanding exhorbitant hourly fees and avoiding steady work.
Admin
The funny thing is the original post has nothing to do with this article. +1.0e127
Admin
To be on the safe side he should never apply anywhere. 100% probability of success.
Admin
Well, the duplication is just "speedup reserve" - delete one to speed up your application if you need to. Delete everything but the last few lines for an even greater speed gain. (Yes, I doubt that's the real reason.)
The (float) assignments weren't there initially - the junior developer had been introducing some floating-point weights and was wondering why they didn't show up in the final output, so he asked a coding guru for help who, in passing, gave it a glance and remarked "no wonder, the results of the multiplication get implicitly cast to int". The junior developer then looked up "cast" in the manual and made sure the result was properly cast to float instead. (Sounds plausible to me.)
Admin
Hmm. This looks familiar. I think I was there. I was one of the in-hose developers. We were powerless to stop it. All we could do was watch in horror.
The horror.
THE HORROR!!
Admin
... and the other 80% are either wives, or sisters, or both?
Admin
Or from primary school grammar lessons, apparently...
Admin
Are we allt alking about an implicit cast while this is a school-example of an explicit cast?
Admin
Admin
Looks like 5 dollar engineering to me?
I thank God every day that people hire moronic consultants/contractors/software engineers that don't know how to write clean and efficient code because I know I will have a steady stream of contract work to fix these types of problems.
Admin
Admin
I work with 'Randy' and a few notes:
A. This code "works as designed." I questioned the lead contractor on the project and he confirmed that it's execution behavior is intentional. It is not an error.
B. It compiles and runs (in production)
C. The optimization: return 2 * probeility / 100; is pretty close but sorry, you broke the code. You missed that minScore is a member (and it is used later.)
Admin
My bad; the above is wrong for what was posted. There are actually two versions of this method in the same class with slightly different implementations. One sets a member and the other doesn't.
Admin
To clarfiy: the code posted was modified from the original. minScore is a float declared as a member. It's not an int.
Admin
In-hose developer. Does the company use them to just blast out some code?
Admin
I think it's similar to "prolly".
Admin
They are the ones who get hosed with the maintenance of the crappy code after the consultants disappear with their big checks and leave shoddy documentation behind.
Admin
Well, that would make me an in-hose developer then! I've been trying to clean out the crap left behind by my predecessors for 5 years now...and thanks to management's fear of change I've still got most of the system to go.
Admin
Heh, just found this gem on Metro PCS' website. This is the whole file!
Contents of prefix.jsp:
Admin
Yes, please do. It would save us from what ever monstrosity you might make.
The coder doesn't even understand the difference between an int and a float. He even tries to cast a float into a float then passes it to an int!?
int minScore = 0; ... minScore = (float) (minScore + 6.1);