- 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
I'll see your fist and raise it...err never mind.
If I had a dollar for every project I got placed on that was developed like this I'd be retired by now. This is the type of stuff that makes me want to go flip burgers for a living.
Admin
I have seen the same problem with incrementing primary keys using "MAX(intuserid) + 1".
Can't really disclose the problem that it caused, but it was very bad.
Admin
I was wondering why my gym was spamming me with male enhancement emails.
Admin
No he wouldn't - Waluigi has an inverted "L" on his cap.
</pedantry>Admin
Admin
And then they wanted to sell their services to other "Gyms" so it was requested that the other "Gyms" be allowed to send "membership" information to it.
Jory's boss said, "Well since we can send information to it, what's so hard about allowing other gyms to send information to it?"
At which point and time Jory began a 3 month journey down the road of educating his superiors and letting them know why direct database access is a bad thing.
Next they decided that since they have these email addresses for members, they should send mass emails out to these users as well. To do this we weren't allowed to use a mass emailing service. Also, you can't use the same servers or ip addresses that the original servers are hosted under in case we get blacklisted. Solution: let's use the ip addresses from a different company that we own. Nevermind that the two systems are nowhere near each other physically. Nevermind that it would require a process to be setup that pulls down all 700,000+ email addresses, and separate email templates for each location (that were setup in the aggregator) to this new server. Nevermind that there are people that spend their lives figuring out how to get spam through email filters and now Jory was required to figure that out as well. Oh, and lastly nevermind that they didn't actually want to pay for a server, or software, so a glorified workstation was used and mercury mail server sent the emails.
Admin
Just wasted half an hour of my life looking at the super mario wiki - thanks to you...
Admin
And I'll be spending the next half hour there, thanks to you...
Admin
Admin
Well, that post was worthwhile then.
Admin
Frankly, the solution is correct for what passes for the architecture.
Admin
I'm missing something here....what then happens (more specifically than a bunch of emails go out).
Admin
Completely irrelevant to the article, I really enjoy the new Irish Girl ad. Improves the site aesthetics immeasurably.
Admin
I was expecting a variation on:
Each gym would print out a copy of the application and mail it to the mother ship.
The applications would arrive by mail, be opened, then put on a wooden table and photographed.
The photograph would be scaned into the computer then OCR'ed.
The resulting document(s) would then be compiled and a list created for pig boss.
Admin
I'm just curious, how can max(x) + 1 make a duplicate key?
Admin
Oh damn. If it is one thing that will make me turn on NoScript for this site, it is seeing Irish Girl.
Admin
Two requests go in at about the same time. Both read the current value of the key and get the same value.
With no constraints this is entirely possible.
Admin
if you do a "max(x)+1", and then do it again, and then do your inserts, you get dups. it's a classic race condition that needs some sort of semaphore or other synchronization mechanism around it.
Admin
You don't have google? First hit is a picture. Very clear.
Admin
Oh dear....
Admin
which is why sequences are so handy.
Admin
Um, the real WTF is that the kid didn't automatically see that the code would be handled like that. In a coding environment that badly done, you don't try to fix everything first day or say to the boss 'I can't see how it could be done' simply because it can't be done the ideal way. You work on the problem, fixing what you can when you can. At the end, you end up with better code. For now, you end up with a job and a boss that doesn't think you are incompetent.
Admin
They weren't autonomous calls to the database. So instead of making it part of one big transaction the code went out grabbed the next id number and then returned that back to the code and then it inserted the new record into the DB.
Admin
Admin
Congratulations you found an error in a poster's grammar!
Admin
Yeah. I noticed her to.
Hip-hip-hoooray! Hip-hip-hoooray! Hip-hip-hoooray!
Irish I were really Irish!
Admin
Compiling!
Admin
You've never wandered off on a linky voyage of discovery after finding the information you wanted? WTF??
Admin
nicely put. Unfortunately play fighting in the corridor is somewhat frowned upon where I am so daily wtf has to suffice.
Admin
I think that it's because they came for the pic and stayed for the nostalgia.
Admin
Waluigi is retarded, and so am I since I don't know anything about OOP but it seems:
Mario = subclass of player Luigi = subclass of Mario Wario = subclass of mario? or should be also subclass of player? Waluigi = wtf???
Admin
Occasionally software sucks that you have to work on. The trick is to suffer through the painful code until you have learned how it works, and shown your superiors that you are capable, intelligent, and get stuff done right. THEN you worry about overhauling it.
I wouldn't want to hire someone that was afraid to touch badly written code -- EVERY company has its share of crusty, nasty code, and somebody has to maintain it. An "I can't figure it out" just means you are incompetent.
Admin
Admin
Depends a bit on the situation though. I've had cases so bad that no amount of maintaining would really have made any long term sense and we were just better off creating something new from scratch.
Admin
"I'm just curious, how can max(x) + 1 make a duplicate key?"
If you remove some entries.
Say you have 50 entries max(x) + 1 will be 51.
Say you remove entries 12 and 13, max(x) + 1 is now 49, but 49 still exists unless you renumber the whole table.
Admin
Admin
max not count.
Admin
That still wouldn't solve your problem. Even with a transaction at the serializable level, there is a possible ordering of reads and writes between two concurrent transactions that would result in duplicate keys.
Admin
No... If max(x) = 50, then removing anything other then x=50 will not change max(x) = 50 (it's max, not count).
The problem is more (as many have said before me) that if multiple processes access this concurrently, they both take max(x) = 50 (because nothing higher has been committed), and both set x = 51...DUPLICATE
Admin
In fact I notice that many others have said while I was writing....OOPS - Apologies....
Admin
You're thinking count(*) + 1
Admin
Or you could just, you know, auto increment and move on
/party pooping
// yes, I said poo
/// and poop
Admin
racist condition.
Admin
I agree. An experienced developer would have leveled with the boss and told him that while it can be done, the quickest solution is not the ideal one. He should have also spelled out the deficiencies he found and given the boss some idea of the amount of effort required to set things right or at least requested permission to do a thorough review and analysis of the code in order to come up with a more accurate estimate.
TRWTF was simply telling the boss that he couldn't do it.
Admin
Occasionally? Occasionally I get to work on a codebase that does not suck. Lesson for the kid to learn: Nearly all the code you get to work on in your life will be fubar. Including your own. Get used to it.
Admin
It is obvious that you don't know anything about OOP. But Mario and Luigi are brothers, so Luigi isn't a subclass of Mario. Wario is an evil Mario, and Waluigi is an evil Luigi (and possibly Wario's brother?) You can make Wario a subclass of Mario with the evil bit set.
Admin
The real problem is those **@#$&@#^ random ads. I think I refreshed 20 times before the ad came up.
<me needs_a_life="true" />Admin
I found one too.
Admin
But if Wario is a subclass of Mario, and Waluigi is a subclass of Luigi then Wario and Waluigi would almost certainly NOT be brothers....
Furthermore, if Mario is a subclass of player, then Wario cannot be a subclass of Mario (excepting in the games where you can play as Wario)....
Admin
I see lots of Posters every day. Many of them have Grammatical errors.
(It all reminds me of "Bill Posters will be prosecuted"....)