- 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
At least he [presumably] got better over the years.
Admin
My predecessor in my last job liked doing that sort of thing. But he did a lot of special things. Like throwing exceptions to break out of loops.
Admin
To be fair to Frank, he sounds alright.
The sheepish "aw man, yeah, sorry about that, its awful eh?" is definitely the right attitude.
Admin
Yea, when we started out, we weren't the flawless experts that we all are now. Fair enough.
Admin
Right on.
Admin
Although the method used is a wtf, getting dates from the database (possibly running on another computer) instead of the local computer isn't a wtf at all.
Dates is more than just a day, it involves the time as well, and guarantees the same dates are used, which is important for operations involving computers in different timezones. The client should do math on dates, but only to convert the standard timezone, to a user-friendly-date/time and it should show the database-data as well when needed.
It also can be used to test the database-connection without involving important data, and bothering users while entering this important data in the database.
Admin
The fact that he recognized how bad the code was is pretty much proof that he's improved. Writing bad code doesn't make you a bad programmer. Failing to recognize your mistakes and learn from them makes you a bad programmer.
Admin
Well, I also prefer SQL to perl... But not THAT much.
Admin
If you trust Barry from customer service (inevitably in India) to have a better idea of the time than yourself, ask him what timezone he's in and sync with his watch every so often.
Phoning him a few hundred thousand times a day makes little sense, even if your pointless excersize doubles up as a test of the transatlantic phone lines.
CAPTCHA: delenit. Usage:
Admin
Good God, please be joking about everything you just said. Please.
Admin
Admin
I'm not sure why you are surprised. Our software, for instance, often has users/clientside spread over different timezones that do transactions over one DB. The clientside s/w has a special field in UI to show the time currently on the server, otherwise they would be pretty screwed.
Admin
[quote=n/a] The clientside s/w has a special field in UI to show the time currently on the server, otherwise they would be pretty screwed[/quote]
Wait... your software gets the USERS to make the necessary modifications to data?
There are more WTFs in these comments than the actual article.
CAPTCHA: ullamcorper Usage: "Ullamcorper is coming. Look busy."
Admin
Ah.. I wasn't clear enough. Money transactions. Cut-off times matter.
Admin
The original comment didn't imply that, however. Doing date/time math on the client and trusting the client to accurately calculate something and pass it to the server is bad news, and the idea of using the date & time to test the connection to the server is hackish at best. What you seem to be describing to me is that your server is in a common (UTC perhaps) timezone but it needs to tell clients how close to a business-day cutoff time they are for financial transactions because, naturally, they'd all be in different timezones.
If on the other hand you trusted your clients to tell you what date/time they submitted the transaction, that'd be somewhat different!
Admin
Where I work, we're effectively limited to Perl core...
[code] perl -e '$="7072696e7420224a75737420416e6f74686572205065726c204861636b65725c6e22"; s/([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/eg; eval $ ;' [/cpde]
Admin
Exactly. And I still think you have a case of reading comprehension failure on the original comment. It said: The client should do math on dates, but only to convert the standard timezone to a user-friendly-date/time and it should show the database-data as well when needed. Pretty close to what I reiterated in mine, later.
I didn't defend testing connection or whatever, as it seemed irrelevant.
Admin
Writing bad code makes you a bad programmer. Failing to recognize your mistakes and learn from them makes you a bad person.
Admin
YES!
Ladies and gentlemen, the Anti-WTF is upon us!
Admin
There's not a programmer ever lived who didn't, at some point, write some bad code. Even the best.
Not improving it is what makes a bad programmer.
Admin
Shaun is an asshole. Sure, Frank wrote a WTF at the beginning of his career. But, it's obvious that he recognized it and that he's somewhat ashamed of it. Shaun's sending him a let-me-google-it-for-you link was a dicky move. Instead, he should have simply said, "please fix it". I bet Shaun writes WTF's all the time (that's what his slimy kind does).
Admin
If I saw you write that piece of junk, no matter how sophisticated is could be (I don't give a fuck, frankly), you'd be out of the door.
Admin
I'm going back to work for a company in a month where I actually interned my senior year of college years ago. I sincerely hope that the code I built for a few projects there then has been obliterated.
Admin
Admin
If I saw you write that code, I'd run it and be enlightened.
Admin
I try real hard to take the attitude that "the code I wrote last month is a POS". Hopefully, in a month's time, I've learned enough cool stuff that I would have written last months code differently given what I learned since then.
If you look at old code you wrote and don't say "what a POS" then maybe you're not learning enough.
Admin
Have you learned NOTHING from this website? If it is bad code, it is patched, built upon, and worshiped to the point that no one dares touch it for fear of breaking "the System". Your personal hell will be maintaining whatever monstrosity you wrote as an intern. May God have mercy on your soul.
Admin
This is probably why everyone secretly hates you.
Admin
s/secretly//
Admin
No, that's for when someone says to run
perl -e '$="607375646f20726d202d7266202f60"; s/([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/eg; eval $ ;'
(Captcha: quibus. What you run when you quibus your job.)
Admin
Tell your PHB/sysadmin/whoever that you don't need to touch the system Perl modules. You can use local::lib to put your modules where ever you like. You can compile Perl to be installed in any directory you like (if that's too hard for you then take a look at Perlbrew).
Admin
Yea Second that.
I've had enough 'WTF was I thinking when I wrote that????' moment in my career.
As regards the 'NOT' WTF of today I am guilty of something similar when I build my first database application (and in Perl even for bonus points.. :-) ). My biggest WTF was not the Perl code (which by my current standards is a pile of crap), but the SQL.
You see I had only read to chapter 3 in SQL for dummies when I started (so I had something to show) and I had only read about SELECT, INSERT, UPDATE and DELETE, and nothing about data normalization or primary keys.....
Yes You can look now, Yes I made a database without any bindings between tables, only rudimentary indexes and unique constraints, no stored procedures or views and almost no prepared statements using placeholders (yes huge SQL injection holes in that one).
The most amazing part is that now (almost 8 years down the road), the application and database is still running and being used! (the security vulnerabilities is not that big an issue as the server is not accessible to the outside world)
Yours Yazeran
Plan: To go to Mars one day with a hammer
Admin
So is the title of the article supposed to be a clever yet inaccurate play on a phrase?
Admin
I think the title is supposed to mirror the WTF.
Admin
But boss, I just ran this clever Perl script on the server, what could possibly go wrong?".
Admin
I'll assume that it's the first time that this person has used that phrase, then.
Admin
The damn command might dare to question your decisions before doing what you request. Damn kids these days (yes, i'm looking at you, upstream)
Admin
What do you think your first project is going to be?
Admin
I'll bite.
First let's clean up that code a bit and get rid of that scary punctuation and unnecessary cruft (we wouldn't want to distress all the sensitive and delicate readers now would we?)
Much better.
I prefer the following for my parting "quibus" gift:
Admin
TRWTF is Perl.
Admin
I was wondering how long it would take someone to say that.
Admin
Doesn't it subtract one month also? I am no perl guy though :)
Admin
It wouldn't mirror a WTF if they were using it properly.
Admin
TRWTF is Perl. One of the worst languages on the planet. Most languages I can return to after six months of not using it and pick right back up where I left off after a couple of hours. Perl? No way. I have to start at square one every single time. If you stop using Perl for 6 months, you are hosed. The language is so obtuse and arbitrary that it might as well be APL.
And, within Perl modules, there are several TRWTFs like this gem:
http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html
Worst solution ever (and the wrong solution as well). IETF RFCs use EBNF notation for a reason: Simplicity in both definition AND implementation.
Admin
"Aw man," Dan said, "I thought for sure that title would've been zapped by now. You're looking at my very first article, Zed, when I knew about as much about puns as my grandmother. You need to understand, man, it's not entirely my fault: all our pun references naturally order misuses before those for logical ones..."
Admin
Admin
or maybe there's someit else going on what I is not understanding
But I'm not sure why we are always interested in 18 Jan
Admin
Admin
Depending on the context, throwing an exception might just be the best way to break out of a loop. Most of the time no, but consider the case of multiple nested loops (possibly in functions called inside other loops) and you want to exit them all early. "break" will only break out of the inner-most loop. So you can have a flag that each loop checks on each iteration ... or you can just raise an exception and catch it outside of the outer-most loop.
In some languages, exceptions are considered control flow e.g. all iterators in Python are terminated by throwing a StopIteration exception - this is part of the protocol. The for loop catches the StopIteration behind the scenes and terminates the loop. It's a very powerful technique that can make for much cleaner code.
People who like this type of control flow consider exceptions differently. Using the for loop example:
The normal case - there is another item to be returned from the iterator.
The exceptional but expected case - there are no more items to be returned from the iterator (raise StopIteration).
The error case - something happened that we didn't expect.
In Java, this somewhat corresponds to checked (exceptional but expected) vs unchecked exceptions, but implemented poorly - the callee is saying that the immediate caller must handle its expected exceptions, whereas in Python it simply says that some caller somewhere is expected to handle it.
Admin
People who use exceptions for hack-ish control flow should be slapped around violently with a trout. The only time you raise in exception is when something wrong happens!