- 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
Looks like they're directly translated from LINQ.
Admin
Every time I see code like the above, I want to start stabbing people.
Why?
Er, because eventually they bring this habit to C or C++, and create jolly bugs (er, it returns "R"...).
Admin
Here's hoping the comment box will handle Markdown.
As for everything else wrong with this...
Admin
I love when people say a particular language is crap, when in fact it is the "programmers" who type crap and then blame the platform for being somehow inadequate.
Admin
I tend to call a language crap when the vast majority of programmers and online tutorials are crap (e.g. PHP) because this means the language itself breeds more crap programmers, who will write more crap tutorials and then become crap managers on crap companies using that crap language.
Admin
TRWTF is the use of the word stream to describe an enumeration.
Admin
Obvious fix for the exception is
Everyone knows a negative value is an error, right?Admin
Too bad there isn't a way to create some sort of Globally Unique token that could be used as an IDentifier.
Admin
For anyone looking for better code, some options are below. Which is more readable to you is a matter of taste, but I expect to get lots of angry feedback both ways ;)
Of course, storing the PK as a string is a giant WTF, but for the sake of this exercise let's pretend that can't be changed.
Admin
It should be "PR#6" because that's how you reboot an Apple II.
Admin
You can program perl in any language, and I've seen two perl codebases that were amazingly clean, readable, and maintainable (really the only thing that matters) - but they did that by not using most of perl, treating it like it was C.
Languages just have a code smell - how baseline unmaintainable their code is if you just write code without discipline. And bad programmers are attracted to those with stronger code smells, like flies to crap, because it's easier to bang crap out in completely undisciplined languages - but you also find them in other rooms of the house, buzzing around confused when someone closes the door and traps them in C#. And then they will probably write perl in C#, you're right there. But there are crap-encouraging languages.
Admin
Why are all the IDs for the entity available to the entity when creating a new ID? What happens during multithreaded operations when an entity gets an ID, then doesn't get saved to the DB immediately and another entity comes in on another thread using the same ID and gets saved first?
Generated IDs are the only way to go.
Admin
Hey!
You finished early!
Great!
Cache it, ship it, make the next one better please.
If anyone complains, send them to sales.
Who's sales?
YOU.
and if you are going to be doing stuff like this, I gotta get a taste. Because next time, there won't be a next time.
I DONT CARE.
Admin
It stopped being an enumeration when it returned "PR1" ("PR" + 1) in case of any error. Then it just became an indexed stream, or indeed list to be processed. I'm already envisioning a future event where two DB need to be reconciled after a split and they find out that there are multiple rows with the same ID (because at some point the row with the highest ID was removed and any new element inserted). That's a poor DBA who has to deal with that (or, if he's payed by the hour, a rich one of course).