- 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
yeah, you could - you could even do it in one hit - but that could cause there to be a simultaneous change to a score of deployed production databases, a whole host of configuration files etc yada yaya. Far better solution to put something like the above in, then once the code is there to allow both spellings (correct and incorrect), you can go through the various production systems and raise a change-ticket on each one in turn, do one a weekend till they're all done.
BTDTBTFTS on a system that had a similar problem with spelloes. I still contend that if computer programmers know they're dyslexic, they pass their work over to a literate colleague whose job it is to correct their fucking stupid mistakes. Not to do that is the real WTF.
Admin
If they're unregistered they're fake, so fuck off both of you shitheads.
Admin
I shared an office with someone who suggested that the value of pi will change if they discover the universe isn't flat. I never was able to persuade him he was talking bollocks.
Admin
Yeah, well that's probably because you're a stinky-foot duck-plucker.
Admin
Man, we should all be writing GUIs.
Admin
86400 seconds? I'm guilty of that!!!!!
Admin
He's bound to get shirty? What's that, and how do I get that way?
Admin
I came here to say the same thing.
Admin
If you calculate it from first principles, then he's wrong.
Where did you get your pi?
Admin
Good grief, that's a bit personal. Let me put it on record that I do not pluck ducks. Chickens, maybe, but never ducks. No quack.
Admin
'Is a single-qauted string' is a single-qauted string.
Admin
The only time you "work out pi by measuring a real circle" is when you're in grade school with a dippy old bat handing out yarn and cocoa tins.
In contemporary mathematics, Pi is not defined as the ratio of a circumference to a diameter. One of its properties is that in the Euclidean plane, circles satisfy that famous relationship. In the non-Euclidean plane, circles fail to have that property - but you don't go redefining pi according to the particular curvature of the frame of reference you happen to be using at the time. That's even more fucking stupid than confusing "its" and "it's".
A simple way to define pi is pi/4 = 1 - 1/3 + 1/5 - 1/7 ... but it's impractical (and I may even have got it wrong - hey it's late here and I can' be bothered to look it up).
Admin
+1 for the quine.
Admin
I'm trying to picture the single 'if' myself....
Admin
Too foten we see people saying "That's bad because my lecturer (or some guru I used to work for) says so. Misusing anything (as we have seen in the past) is probably bad practice, but that's not to say that all usage is bad practice.
Admin
7 days in a week, 24hour in a day, 60 minutes in an hour, 60 seconds in a minute etc. Not really expecting any of these to change, and I have little issue (provided they use comments) with these being magic numbers (especially when people get to 86400). Maybe something like:
I would hope programmer's can work out what 24, 60, 60 mean here, even if I have worked with some who might struggle with 86400 Of course, I could also handle it as
but this feels a little cumbersome for a fairly straightforward calculation
Admin
Either way, 1576, 384, 3,7. THey're all constant....O(1).
<disclaimer> I AM BEING SILLY, BUT FEEL FREE TO ADD YOUR OWN LECTURES ON BIG-O NOTATION ANYWAYS....
Admin
#define DEFAULT_TIMEOUT 100
We can change this value for a future build if we find 100 is insufficient. While the actual setting might be read from a config file, we set up this value in case there is nothing present in the config:
Things that are constant in the world (number of quarters in a whole, for example) are usually expressed more efficiently as numbers, with a clarifying comment as necessary....
Admin
Admin
Admin
Admin
Admin
Admin
An excellent chance to show off VB's "Select Case" awesomeness:
Admin
So, would getQuarters() work for the Maya calendar? I'm just not sure.
Which reminds me of my contribution to humor at work earlier this year. I created a script that converts mm/dd/ccyy dates to the Mayan calendar (long and calendar round); and also converts long-count dates (lc.lc.lc.lc.lc) back to mm/dd/ccyy.
Then I wrote this deadpan tip on how to use the command to prepare for our upcoming conversion to the Maya calendar (because of the end of the world in 2012, of course) and sent it to everyone...
...on April Fools of course.
Some people thought I was serious, even though I mentioned at the end of the article that, if they questioned my sanity, they should take a closer look at the date at the top of the article.
Admin
Admin
I'm not the pheasant plucker, I'm the pheasant plucker's mate And I'm only plucking pheasants 'cause the pheasant plucker's late.
I'm not the pheasant plucker, I'm the pheasant plucker's wife We're all day plucking pheasants, it's a pheasant plucking life.
Admin
I use code from this site all the time. It's always way better than my own.
Admin
Admin
isn't that exactly what he just said?!
Admin
I'm not the pheasant plucker, I'm the pheasant plucker's son, And I will not pluck the pheasants 'til the pheasant plucker comes.
Admin
I usually just write: // Here be dragons! That does the trick.
Admin
Yes but there's more to it than that. If you need to use 24 or 60 in another context, it's important to understand which 24 and which 60 are used in each particular context. If you needed at one point to investigate the 60 used in the other context, you don't want to have to get it mixed up (especially with a "search" tool) for the places where you might have hard-wired the number of seconds in a day ("because that's never going to change"). So if I saw code where 60 was used as a magic number for number of seconds in a day, I'd change it to use a parameter. No quack.
Admin
Unfortunately in some more-or-less important application languages, "fi" is a reserved word for what in sane languages is indicated by "end if" or the closing of a curly.
Admin
This needs to be optimized:
Admin
I always signle quat my strings. I like nicely qauted strings. What's wrong with that?
Admin
"while reconfiguring Sybase stored procedures for a custom version of an HL7 interface application, I stumbled upon this useless-yet-used everywhere procedure."
That's clearly the result of something that got refactored and probably previously did something else. You think management wants the programmer to rip it out everywhere, taking extra time and potentially introducing a bug, when it could just be left as-is after it got refactored into nothingness? Heaven forbid it ever became needed to do something more complex again.
Admin
"Is a sentence fragment" is a sentence fragment.
''Is a single-qauted string'' is a single-qauted string. Of course I single-qauted the string, so there are no escape characters.
CAPTCHA: bene there, done that.
Admin
In C, 246060 == what?
If you answer 86400, take a portability penalty.
If you answer "It depends on the size of int", congratulations. On 16-bit systems (not so may of those around now, I know, but bear with me), 246060 is 20864, even in "long seconds = 246060;". (Listen to the voice of experience, and bear in mind that I haven't had any reason to deal with C99, so I don't know if it is different there.)
If you use the symbolic constants, you can stick an L in one of them (probably HRS_IN_DAY), and then the result of the multiply will be a long everywhere you use it, and consequently it will be 86400. You will never have to track down the one place where the multiplication got 16-bitted because you left off the L.
Further note: #define SECS_IN_DAY 86400 will work correctly, as the compiler will expand the constant to be a long.
Admin
Admin
"exit for" exits the current for loop. However, the original code has 3 "for" loops, and the second and third loops will run even if we exited the first "for" loop. In fact, if we exited the first "for" loop, then we are guaranteed to go through the second and third loops completely - we can't possibly match the tests in those loops, so we cannot possibly end them early.
Admin
I guess it depends what language you're using for identifiers. If you use English, then THREE_THOUSAND_AND_ONE is correct. If you use American, then you might prefer THREE_THOUSAND_ONE.
Admin
Being in the education software industry, I can say with certainty that there are definitely cases where you'll need all 4 quarters. Why you've hard coded the number of terms, however, doesn't make sense to me. Why you've called it quarters makes even less sense.
Admin
Its pretty amusing when Americans choose to correct something when they're just wrong.
We know they're wrong because they claim their speaking English, but getting all the rules mixed up.
If you want to correct us on our own language, please remember that you are simply wrong, and your "4th Year" teacher probably ought to have explained that cultural truism to you. Although, had you started Kindergarten a year earlier, maybe you wouldn't have been a year behind your entire life, and might have worked this out for yourself.
Bows I thank you! Bows
Admin
Also - I know I made some terrible spelling mistakes in the pos above, but frankly, since its my language, I have carte blanche to abuse it how I like... including via the inclusion of french (lower case F intentional).
Admin
Alex, you're slacking. QUARTERS_IN_A_YEAR isn't really a wtf, and certainly doesn't fail as has been pointed out. I can see very valid reasons for wanting strings representing the index of a quarter starting from one, when still referencing them in code by 0. If, for example, you were to display to a user "Quarter #X", you wouldn't want to display 0-3, but 1-4. This function retrieves an array for such a use.
Also,
"// Get today's date, and also format it in a more human-friendly way"
was posted twice.
Admin
Admin
Ummm ... I think that was my point.
Admin
Here's my suggestion: http://johansens.us/sane/offthewall/cal.htm
Shut up, Akismet!
Admin
As to:
I think I know languages in which this creates : a) a 3 character long string with trailing \0 character, making the length equal to 3 b) a 4 pseudo random characters which happen to lay in the uninitialized memory, making the length anyhting between 0 and .. Segfault c) a 4 bytes array initialized with all zeros, making the length equal to 0
but what I am really interested in is your debate about magic constants!
P.S. in what language does it define a string of length 4?