- 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
itsSeed is a member field. Here's your clue: this->itsSeed = time(NULL);
Admin
This won't work for very small or very large values. Also, I don't believe it will work as expected for negative values.
Admin
The "<FONT face="Courier New">if (theMin >= theMax)</FONT>" check will fail to prevent negative values as long as this condition isn't true, so negative parameter values can still create an infinite loop condition.
The anonymous poster used incorrect parameter values for their example. They should have used theMin:=-15 and theMax:=0.
Admin
I've noticed that females involved in Software Engineering seem to be better at QA and understanding business requirements than many men. Dont most business decisions and requirements mimic the same reasoning behind impulse buys and lust for designer shoes (without the sticker price)?
Admin
I've known many men who impulsively made decisions to go with the latest "designer" software...and those had one hell of a sticker price.
Admin
While I disagree with the women and CS don't mix thing, it's pretty clear from historical records that Ada Lovelace never did anything but write some papers on how great Babbages machine would be when complete. It's not clear that she had any meaningful understanding of the machine. In short, she is famous for saying 'seriously, I'm actually a genius.'
Admin
Admin
> > year or so after she left
> Women and Computer Science don't mix! ;-)
Hey! :@
(Admittedly, I can't quite this preview thing to work, but I doubt that it's because I'm a woman. Seriously, this comment form sucks)
Admin
i'm pretty sure static class members (aka globals) can be referenced via "this->". however, the naming convention leads me to believe that it's an instance variable.
the wtf about that is that an instance variable is being used to keep track of whether a global (i.e. the prng seed) has been initialized.
Admin
Perhaps adding an entry to: http://brilliant.urbanup.com
Admin
<FONT face="Courier New" size=2>having gone to great lengths to obtain a copy of an out of print biography on ada lovelace [0], i'll say there is plenty of evidence to suggest she was quite capable of understanding the machine. you have to consider the times, as well. being a self-taught mathematical hobbyist wasn't a common thing for women to take up back then - that she did pursue that route, and made interesting observations about algorithms ahead of church-turing's time, says a lot. her life towards the end was kind of depressing: she became addicted to morphine after using it to treat an illness, which probably didn't do much for her abilities.</FONT>
<FONT face="Courier New" size=2>[0] http://www.amazon.com/exec/obidos/ASIN/0875185983/thegreatideafind/104-3701586-1679962</FONT>
Admin
This is a general problem. "Number" and "Value" are pretty useless variable names to begin with. I ran across a variable today called "myThis", which combines two of my favourite naming WTFs in one: "my" and "this"! Both of these are, of course, as semantically bankrupt as "Number" and "Value", and putting them together doesn't help one bit. Might as well call it "yourThat" for all the good the variable name does me as I read the code.
(I've never really liked using "this" to mean "current object", any more than I like Microsoft's "my" naming convention for desktop entities. Both are more of a hindrance to clear and logical thought than a help, particularly in conversations, which start to resemble Who's On First pretty quickly.)
Proper variable naming is at least as important as proper commenting, and for the same reason: the compiler doesn't care about either one, but people reading the code sure do! A misnamed variable is just as bad as a misleading comment. Neither is worthy of the label "professional".
Admin
I basing my statements on a book written by a researcher who was involved with completing a working reproduction of the never finished machine (they had to make some changes to the design to make it actually do anything.) What he found from her writings and Babbage's was that Ada Lovelace had produced next to nothing towards the project.
If you have a links to reproductions of her work, I'd be open to other views. All I can find is that she was able to imagine the uses of computers way before her time. This makes her a great anticipator but not a programmer.
In all reality, though, the first programmers were women. 'Computer' used to be a job description. It's what female mathematicians did before the programmable computer. When ENIAC was created, the programmers were the people who were most familiar with the alogrithms: the female computers.
Admin
Prefixes like "my" are an easy solution for a conflict with reserved names, especially when it comes to variable names like "value" or "number". Today I tried to compile a very old program, which had a function "pow" that conflicted with a built-in function of the compiler; so I changed it to "mypow".
Admin
When given the choice between a 'semantically bankrupt' (must remember that one) and a verbose name, I opt for the latter.
I'd have named the function 'raiseToPower' or 'raisePow'. 'mypow' immediately causes me to think oh you can do better than that.
Admin
*when I'm seriously working, of course. If I need to quickly sketch a snippet, I'd probably have called it 'mypow'. Or 'powpow'. Or 'poof'.
Admin
Actually it was just curious if the compile (freepascal) was able to compile the program (Turbo pascal). I'm not even sure if the "pow" function in this program really meant "raiseToPower".
Even if so, if that was a serious program, I would have had to check if it makes sense to take it out and use the built-in function. Anyway, the prefix "my" is a good indicator for "likely reinvented the wheel".
Admin
Well, that depends on the context. For example, in the implementation of a hash table (or any kind of lookup functionality),
"value" has a well-defined technical meaning.
Admin
The hungarian version of that is "asjf_".
Admin
Drat, threads knit fast around here.
My previous post in reply to:
Admin
I'll be damned. You're right. The folowing compiles without warnings or errors in VC7. Certainly doesn't feel right, though...statics don't belong to the instance...I hate C++. I really do.
<FONT color=#0000ff size=1>#include</FONT><FONT size=1> </FONT><FONT color=#808000 size=1><IOSTREAM>
</FONT><FONT color=#0000ff size=1></FONT><FONT color=#0000ff size=1>struct</FONT><FONT size=1> StaticTest
{
</FONT><FONT color=#0000ff size=1>static</FONT><FONT size=1> </FONT><FONT color=#0000ff size=1>long</FONT><FONT size=1> field;
</FONT><FONT color=#0000ff size=1>void</FONT><FONT size=1> printField()
{
std::cout << </FONT><FONT color=#0000ff size=1>this</FONT><FONT size=1>->field << std::endl;
}
};
long</FONT><FONT size=1> StaticTest::field = 1;</FONT>
<FONT color=#0000ff size=1>int</FONT><FONT size=1> _tmain(</FONT><FONT color=#0000ff size=1>int</FONT><FONT size=1> argc, const char** argv )
</FONT>{
StaticTest test;
test.printField();
</FONT><FONT color=#0000ff size=1>return</FONT><FONT size=1> 0;
}
Admin
IIRC java allows that, too.
Admin
"number" and "value" might be keywords. Easier just to add letters rather than RTFM or hit Compile.
More likely, the author is saying all the statements in his or her mind as she writes them and finds something closer to proper english easier to work with.
Admin
And men wonder why women in technical fields say they have to deal with a ton of sexism.
Admin
Namespace means nothing.
I would have figured out what the function did, determined if it was developed by NIH syndrom, if so, use the already invented (and likely adequately debugged function) and dumped the dupe. Or, if It didn't suffer from NIH, and was a novel function, I would have given it a more descriptive name like:
MakePowSound, PreviousOctalWord, PushOtherWorld, PressOrangeWidget, etc.. (note these names depend on functionality)
or if my "Function to raise a number to a power" were a superefficient über-function, then I'd use hungarian notation and name it ufihPow.
Admin
If you're talking about static fields being accessible through an instance, yes.
The unanimous opinion of comp.lang.java.programmer is that it's one of the language designers' biggest mistakes.
Admin
Wordy McFucking Word, as one of my good friends would say.
Personally, I've not experienced too much in the way of ignorant sexism in my professional life. Online, in fora like this one, is a whole different kettle of fish. It's quite pathetic and it's one of the reasons I've not posted here before, even though I've been a regular reader for a while.
Vicky
Admin
Anonymity gives people the balls to say things they would not otherwise say aloud.
Admin
<FONT face="Courier New" size=2>are you from the midwest?</FONT>
<FONT face="Courier New" size=2>that's good news. at my old workplace, i was told (by a female coworker) that women never got promoted. things like that can occur, but most of the harsh rules in place are a deterrent towards sexist attitudes. ah, that reminds me (classic):</FONT>
<FONT face="Courier New" size=2>Ian: Ah, shit. They are not gonna release the album...because they have decided that the cover is sexist.
Nigel: Well so what? What's wrong with being sexy? I mean there's no....
Ian: Sex-ist.
David: -ist, not sexy.</FONT>
Admin
Shrug. My main reason for not registering before was lack of time, rather than a desire for anonymity, but I've registered now, does that help? I'm not putting my email address up in my public profile if that's what you're getting at: I've done that before and ended up receiving all sorts of delightful things in my inbox.
Vicky
Admin
</font>
<font face="Courier New" size="2">Nope, I'm in the UK. And my friend who says that a lot is Canadian!
Vicky</font>
Admin
OK, I just realised that you might have been referring to the people who made the ignorant remarks in the first place, rather than me. If that's the case I apologise for snapping!
Vicky
Admin
Actually, I wasn't referring specifically to you. To people on the net in general. Even if a person is "registered" on a website, they might as well be a talent sea otter for all one can verify. [:)]
Admin
I've had more caustic things said to me over a misplaced period. No worries. [:)]
Admin
Hi, this is the submitter of this WTF.
Just felt I'd clear up a few things:
1. You can't blame the naming convention (its/a/an/the) on The Genius, it was a naming convention long established by our organization and now followed for consistency. It's not the worst thing in the world, and, as others have pointed out, it does conveniently prevent a lot of name overloading problems with libraries & such.
2. We were mistaken about the crash opportunity - we assumed division by zero would result in an exception, but it does return Inf, even on Solaris. As if that were the least of the problems in this function.
3. In scanning the posts, it seems like everyone here has hit the high points of this particular function. I have to admit that the "reciprocal technique" of generating a random double was always my favorite part.
4. I've always compared this function to the quote by some famous sculptor (sorry, can't remember who) about how to carve an elephant: "Start with a rock, then chip away everything that doesn't look like an elephant."
4. Yes, she was a Mensa member.
-BbT
Admin
One more thing - her name wasn't Paula Bean.
-BbT
Admin
Sure, this late in the game clarification is everything
If I were to work at an organisation that insisted upon unruly and useless warts as a naming convention, my resume would be posted everywhere. Hell, I'd even consider relocating to Elbonia. I can understand standardising on prefixing the name with its type, I can understand prefixing it with its scope, I can understand prefixing it like microsoft does in it's SDK, but I simply cannot fathom the stupidity of prefixing everything with the and its. itsIdiotic.
Depends on whether the hardware has that exception masked out (Floating-point divide by zero) it can be enabled, and at that point will be a crash opportunity. IIRC, there's a way to turn the exception on and off in the C standard library.
Yep, when so many other techniques are totally obvious.
More like throw spaghetti against the wall to see what sticks... seriously.
Good reason to never join Mensa.
Admin
No, that would be better than the function written because it would actually stand a chance of having an even distribution. This function doesn't have a prayer.
Admin
No, it should ( C ) throw the double to an +inf value, from which the infinite loop would occur, since (+Inf - N --> +Inf) IIRC for double & floats.
I expect this was the source of the 100% CPU, and not a very very very small range.
-dave-
Admin
a/an - local variable
the - parameter
its - member data
I'm not sure what our convention is for globals, as I've never seen them in the code. The convention itself was inherited from the commercial product XVT (a cross-platform GUI library), which seemed as good as any to use by the original designers of the system, as it used XVT for many of its clients.
I can only dream of the programmer's paradise you must live in if following an odd but non-horrible naming convention is sufficient to drive you to looking for other employment.
-BbT
Admin
TheOneAndOnly
Admin
Actually it means "bright" or "shining" in French.
Admin
Well, anyone who's studied high-IQ societies at all will immediately realize a few things:
1) IQ is difficult to measure accurately, sort of like programmer productivity - take it with a fair amount of salt;
2) Mensa contains a disproportionate number of people who like to brag about their intelligence, but who don't necessarily actually have a whole lot of it (at a 98th percentile cutoff, it means that if you can get through high school without cheating, you can probably join); and
3) There are lots of high-IQ societies above Mensa, most of which contain much lower proportions of braggarts.
I believe it was Groucho Marx who said "I would never join a club that would have me as a member".
Admin
It seems that neither of the above posters used a little arithmetic either :)
That function doesn't even come close to generating a value from iMin to iMax. If you had iMin = 2 and iMax = 10 you'd be producing something from 2 to (RAND_MAX * 8), which is nothing close to a value between 2 and 8!
The real WTF here is how many people like to dump on other people when they themselves are clueless!
If you wanted to produce a psuedo-random value from A - B you'd do something like:
value = rand()% (iMax - iMin) + iMin; // The simple way that most average programmers would use.
Or better (to use the avoid only masking on the lower bits of the number generated):
double value = (double) rand()/ (double) ( (RAND_MAX + 1)/iMax ) ;
Admin
Are you dumb or just stupid?
The real WTF here is that you're even more clueless.
Here is my code, which I posted as an example. Quoted above. Please notice I said the rand() call needed to be replaced with a bit of code to normalise the number to the range from 0 to 1. I was hasty in my first reply and realised the mistake, and since the forum doesn't allow editing, I simply replied with the correction in the post.
which outputs:
Hmm.... Numbers from 5-10. Gee, Who'da thunk.
Gee, your second function is a stellar example of fitting the specs. Returns numbers from 0 through 10.
Mike "The real WTF here is bagging on someone for being clueless, when you yourself are clueless" R
Admin
Admin
Well, sure, just guess what random numbers you'll get with that refined implementation on implementations where RAND_MAX == INT_MAX.
Admin
Oddly, I haven't had to deal with sexism. I did have one interview where they warned me that many of the clients wouldn't think I was capable (car dealerships), but I didn't take the job -- the offered salary sucked. At my current job (gov't contractor) women get promoted at the same rate as men, and while men do outnumber us ladies, we are treated uniformly.
And I can attest that at least here, women perform uniformly as well. I've had the pleasure of working with some very dedicated, talented, and experienced female engineers, none of whom would want anything to do with this monstrous piece of code -- except to perhaps mount it on the wall of their cubicles to laugh at.
Admin
CalliArcale wrote:
> mizhi wrote:
Other than ability and potential, the only other criteria I considered was "would they fit into the team?".
I occasionally rejected somebody who's attitude was bad and who I thought would disrupt the team.
I repeatedly hear stories of employers who won't hire women, or people of a particular race or religion.
I've even been on the wrong end of that. Last time I was job hunting, I spoke to a number of people
who wouldn't consider me as I was too old (forty-something).
Such is life.
Admin
If min and max are < 0 and min < max then the for loop never terminates because:
counter -= min
but min is negative, so counter gets larger and will never be "less than" anything.