- 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
And if that one time zone is Arizona, you don't have to muck about with Daylight Saving Time and have one night a year where there are two 1:34am's.
Admin
Admin
Who actually builds any WebForms projects these days anyway?
Admin
-- Useful information for when you want to show off how smart you are. Impresses chicks. (So I've heard.)
Admin
Amen brother,
Aeons after the earth has decided it's borne the weight of the Himalayas for long enough, long after the insects have won the battle with humans, and long long after ITAPPMONROBOT last searched for the reset button, my code will still be dealing with DateTime objects perfectly.
I like your style.
Admin
Early binding improves performance, the opposite of what you seem to think.
And these variables were in a very small function. I'm not seeing the need for verbose naming for such a small scope. If you can't look into a 5-line function and determine the use of a particular variable through context alone, then you probably should be in a different line of work.
Admin
Chuck Norris broke his leg when he tried to roundhouse kick function doseq().
Admin
Mine start with
function dofrist()
Admin
Admin
Remember, remember the fifth of november!
Admin
Oh thats easy, just use a sleep(1) wrapped in a semafore (file lock).... Evil grin
Yours Yazeran
Plan: To go to Mars one day with a hammer
Admin
It would be interesting to try and tie this WTFs back to forum posts somewhere, to see if this weird ass epoch offset approach was his own idea or something he needed help on and posted to some forum asking "How come it's wrong!?" and the classic "I can't show you my code, obviously, because I don't want you to steal it, just tell me how to fix it."
On a side note, Unix epoch isn't even needed considering the function's purpose. So leaving out the context would have worked just as well...
Admin
I feel your pain ...
Admin
It's not only performance. If you happen to use a variable that is defined outside a function, ASP/VBS will reuse the variable (effectively making it global) unless it is declared with dim.
This VBS will show 12 3 12, and if you disable the dim it will show 12 3 3. Can be very confusing and also result in endless loops when calling a sub in a for loop and there is another for loop with same iteration variable in the sub without using dim.
Admin
-Harrow.
Admin
That is the best comment possible!
Admin
No no no, don't be silly, he means: "... till the code no longer exits with an error message when presented with the single test case the developer has designed the code to work on."
Admin
You mean there's another way?
Admin
Date/time handling can be a whole new WTF. I've been delousing an outsourced app lately which captured daily data. How do you store that? Well, of course, you give each day its own row in the database ... with a "week" column and a "day" column. Data for Thursday would get stored with Monday's date in 'week' and a value of 3 for 'day'. Except for daylight-savings weeks, when it stores Sunday's date in 'week' instead (but still sets day to 3). Oh, and occasionally some get stored with Saturday instead. Maybe from a user accessing it with wrong timezone settings - all the date calculations were done client-side.
What gets stored with 'day' set to either NULL or 7 depending which table you're in? Totals, of course (generated on the Javascript front-end and passed back) - spares the poor database engine the stress of adding up, y'see...
Apart from corrupting the data in fun ways, the front-end goes and creates HTML for every week in the project's timeframe, then hides all but the week being edited. This of course worked in initial testing, then breaks horribly with long or complex projects as IE 6 (yes, have to support that, too) chokes on 100,000+ form fields at once.
Admin
Then users start complaining that it works slowly, and corrupts their data.
Then it ends up at here, poorly anonymized.
Of course there's simple solution, just add comments like
// FIXME: ugly and stupid
and my favourite
// TODO: add error handling
Admin
Much much better . you can use server-side javascript to do the sleep, much better since js's sleep actually makes use of the CPU for the duration ...
Admin
There can be only one . time reference for a machine. trying to make that your local piece of crap timezone is retarded. don't do it. it's not simpler, it's just worse.
Admin
Not really . not when you're doing such overly simplistic stuff. there is NO point in having stupidRetardedLongUglyVariableWeiRDcasEName declared.
Admin
Unix Epoch specifically isn't . but you can't have unique ID's without a time component. the only implementation would be an ever increasing number, transaction safe and that would practically mean a call to the transactional id engine for each id, including disk io. - and that sucks.
Admin
"But even stranger than that, Option Explicit is never enabled in any of his scripts"
That's not strange at all. This way he can use the variables for whatever data type he wants depending on the function. If that's not a flexible design then I don't know what is. I give it 11 for it's super awesomeness. If you chucked in some XML it might even be enterprise quality code.
Admin
So you mean they couldn't give a flying toss.
Admin
Oh come on, thats basic code optimization. Of course it takes longer to calculate the time difference between now and 1970 than between now and 2007. That's over 37 years he does not have to calculate!
Admin
Admin
It's not that it is hard to get the meaning by mentally parsing the code, but why on earth should you? Essentially coders who relax naming standards 'because the function is simple' are the same numpties that would use any old excuse to churn out shite (sore point at the mo, sorry, wrestling with some funky technical debt here). All methods should be short anyhow, doesn't reduce the need to document what is going on.
Admin
Admin
You make a good point about locale pitfalls in the date literal, but I don't think that was the case here. Your result agrees with mine. 2007-11-04 22:04:34-05 is the same as 2007-11-05 03:04:34+00 and 2007-11-04 19:04:34-08.
You are also correct about the 13 second error (instead of 11). That's what happens when I do math myself instead of making the computer do it.
Admin
Admin
Of course he uses a, b, c, d, and etc. You have to be careful with that new-fangled stuff like a1, a2, a3, b1, b2, b3, and etc.
After all, razor-edge = bleeding-edge.
Admin
Admin
No they're not. They're shit like you.
Admin
I understand the whole ‘beauty of code’ thing, but there’s also the ‘beauty of productivity’. . If he can knock out code in a hurry, if it works well enough to get the job done, and the client is happy trading solution time for the occasional error, what the hell, it’s still a good deal. . I can understand the whole dim a,b,c,d too. I do the same thing all the time. You start out not knowing how many vars you’re going to need, and you never get around to cleaning up the code once you’ve got something that works well enough for the problem. . I know that in a perfect world, there would be a committee to debate the functionality. There would be flowcharts printed in color on bonded paper. There would be hundreds of pages of documentation that no one would read. There would be meeting after meeting, conference calls, e-mails, and a great deal of face-to-face meetings over lunch at the home office. . But the practical reality is this: the end user doesn’t care if the code is clean. Given a choice between ugly code that works tomorrow and beautiful code that works next year, what do you think they will choose? . And you know what… they’re right.
Admin
Then again a lot of my code probably belongs on this sight and would give "good coding standards" people a stroke.
Admin
Ohh yes. Security is still on the 'TODO' list. The outsourced server-side code had a huge security library bolted on which checked very carefully that the user was indeed a valid one before letting them read or write user data. It did forget to check that it was your data you were accessing though ...
It had 3 layers of access: user, company admin, system admin. Company admins could reset users' passwords. ALL user passwords, whichever company they were associated with.
(Inputs are pretty solidly checked now, at least, but after the last round of layoffs time to fix bugs is in short supply.)
Admin
By putting this expression through Google translate a number of times. You can find out what he meant, but it is certainly less clear than when he wrote it.
(Original: "Just like this sentence I put through Google translate a bunch of times. You can figure out what I meant, but it's definitely less clear than when I typed it." English -> Portuguese -> Spanish -> Norwegian -> English.)
Because of course the only two options are single-letter names and 43-character, multi-word names.Unless you think that, say, base and diff or something are "stupid retarded long ugly variable weird-cased names".
Admin
Your sales team aren't going to turn down a million-dollar contract just because it happens to be in a different timezone. They're going to make that sale, complete with a shipping date of next month and expect you to hit it easily.
Then what happens? Oh yes, you go on a death march trying to find every single place in the code where a date or time is used. You'll miss some places, causing odd bugs that only pop up in the customer's timezone on certain days/times - probably when you're asleep so you end up woken up to fix it "RIGHT NOW".
So you end up at least exhausted if not fired.
For some reason it's US based software that tends to be the worst for timezone issues - a lot caused by communication between machines in different timezones, differences in date formatting and daylight saving time changes.
Admin
Beg to differ. If you write it properly in the first place, there's no need for you (or someone like you) to keep having to knock code out in a hurry, because it works neatly just the way the customer wants it.
Incompetent engineers come in two flavours:
a) the sort who bash out shit quickly and hope that's what the customer wanted - but never mind if it's not, because they can quickly bash out some more shit, and
b) the ones who haven't got a clue how to go about coding, so instead of designing something concrete they waste time in creating management reports, planning charts, development meetings, anything but actually committing code to keyboard, in the hope that someone out there will accidentally tell them what to do.
I understand from your own false dichotomy that you've only ever met incompetent engineers.
Admin
A wise man once told me that you solve today's problems today, and tomorrow's problems tomorrow. If a salesperson sells to an out-of-timezone client tomorrow, then that's when the organization should worry about any time zone issues. Otherwise they're just wasting cycles they could be putting into other features. Everyone knows that in software sales, there is a bit of vaporware in every sale, so the rep can just "sell the gap," and bake in some time for the dev team to fix any issues. Besides, there are always workarounds if the software can't be upgraded in time.
Admin
Oh, there's a place for all the above concepts. I know how to write elegant and efficient code, but on occasion I have to consider the scope of the task at hand. Like every other programmer, I've written hundreds of short, throw-away programs designed to solve one problem one time and there's simply no point even to documentation.
In "The Psychology of Computer Programming" there's a story of the fellow working to get data inputs for a program to be "super-efficient." The professor he was working for was getting very frustrated waiting for the results of the programmer's work... and it was yet another run-once program but the programmer was off obsessing over the input routines.
When I was a young programmer, I got caught in an inter-department war. The battle that I think got me fired was over a sort program. One manager had hired a contractor at exhorbitant hourly rates for a full month to produce the sort program. I mentioned to her and my own manager when we were in a meeting that the program could have been written in an afternoon. She got furious and left. My manager asked me if I was kidding. I said "no" and he got an evil grin and said "do it." So a couple hours later I had a clone of the other progam working (how hard are sort programs, really?) and took it to my manager who then dropped it off on the other manager. I gather there was some shouting involved. The next day she's back with a triumphant look as she shows us her figures. It seems that on a few million records her sort was a few milliseconds faster. I knew how much the contractor was making per hour and I asked, "the company paid him $15,000 [1985 dollars] for that program. Was it really worth it?" Oh, well. Me and my big mouth, but stress of being there nearly put me in the hospital. I could probably write a few WTF stories about that place.
Admin
I had a similar experience one time involving surveillance cameras. I was down to the main office for meetings when I heard that they were about to spend $3000 for a video surveillance viewing/recording station. I went out at lunch hour and put one together that cost them a total of $200. . But back to the main point…
. Like I said, I’m a big fan of clever coding. I’m in awe of those who can knock out in 5 lines what it takes mere mortals like me 30 lines to do.
. But in the painfully real (and fast paced) world I work in (the restaurant industry), there is no next week. I’ll get a call at 8pm telling me something that needs to be deployed in 120 locations by 8AM the following morning. That’s just the way the restaurant business works. And that sort of thing happens all the time. . And the reason for needing the code has nothing to do with problems in prior code. It’s just the nature of that fast-paced beast. For example: You find out at 8pm that your supplier is changing case sizes on a major food item for deliveries that are arriving tonight. Stuff like that. No one is to blame. Nothing could have been done to prevent the problem. It’s just a sh*t sandwich that‘s your job to eat. . And in a case like that, the client will never see the code. It will be run exactly one time before being deleted. It doesn’t matter how big the file is, or how pretty it is. The only thing that matters is that it has to work and it has to be ready by 8am. . There are, of course, the other programs. The ones that people will use for years. In those cases, of course you revisit your code, you clean them up, you document them.
. But in a results-oriented and time-critical environment, as I said earlier…. Ugly code that works tomorrow is better than beautiful code that works next week.
Admin
Admin
And there is the problem-- that and the other developer who asserted that because he didn't know what he was going to do in the code, he'd just declare some variables and get started typing, as if that was just fine. If you don't know what you're going to do and have no standards for how you do it, your code will inevitably be shite and you won't even know why anyone else would think so.
As for writing one-off scripts (or tools or whatever)-- if you write crap code each time, I can understand not reusing it. However, I have a library of quick-response code I've written for systems I've supported over the years, and I can respond much faster because I still put the time into making them reasonably well structured; I can call up and reuse decent code because it works well and I can see clearly what it's doing, so if I have a different need, the basics are there and tested, and it's easy to see what to do for the new need.
Imagine:
float fnGH(float a, float b) { float z = 3.1416;
return f(b*k,2)*a; }
or
float CircleArea(float radius) { float pi = 3.1416;
}
Now-- how much longer did one take to type? I suggest, if you are a professional programmer, the second didn't take any longer than the first. I also suggest that if you are a professional programmer, the first would take more from your self esteem than the typing the second took from your time.
Admin
Who said he was "wise"? Quite frankly I think he was an overpaid shithead. Any cunt coming out with fucking crap like that on my watch would be out of the door so fast he'd break the light barrier.
Admin
There is no such thing as a "short, throwaway program". It's always going to be: "Matt, where's that program you wrote last month for munging the project file? Can you dig it out and ...?" If you're 1% competent, you'll make sure all your short one-off throwaway programs will be written with the same care as you write your production code - and if you find it impossible to write to production quality as quickly and efficiently as you write shit, then sorry, but you're the one who's shit.
I expect you got fired because of your intolerably complacent, pompous and sneering attitude. Now fuck off back under your stone.
Admin
Have you ever seen SpectateSwamp's code?
Admin