Here's a verbatim snippet from a different module in the same library. It's annoying enough to be distracting, but then I'm a little ADHD:
// return result return result; }
Here's a verbatim snippet from a different module in the same library. It's annoying enough to be distracting, but then I'm a little ADHD:
// return result return result; }
Some C code found while looking for a bug in a production library:
int doFoo(myType_t *p) { int rtn = SUCCESS; if (!p) return rtn = FAILURE; ...
We're leaving anyway, why set the local on the way out?
No biggie, won't cause cancer or a core meltdown, but it did in fact elicit an audible WTF?!?!?
Maybe it's because I was in college in the early 70's, but somehow "referer" sounds like an awkward term for "pot head". But I guess you'd spell that "reeferer". :P
I was trying to track down a serious bug, and I found this gem in a C# library maintained by a colleague. Class and variable names have been changed, of course.
public Foo DoBar() { // create bletch instance using (Bletch bletch = new Bletch()) { Kaka kaka = bletch.getKaka(); if (kaka == null) { kaka.Dispose();
I had a critical bug to resolve, not to mention that the colleague and my boss are both a little prickly about me touching this area of code, so I wrote an entry in our bug tracking system about a guaranteed NPE and went on.
The colleague, instead of being slightly chagrined and removing the cruft, has lowered the priority from "Normal" to "Low".
Note that this code is not frozen and gets edited on a regular basis. I am guessing, 'cause no one has said, that the rationalizations are "it would never happen" or "it has never happened" and almost certainly "I have real work to do, quit being a pain in the ass."
This thing, it makes me sad. :(
I've been away from this area of code for about a year, but now I'm back updating a C# utility. When I do a fresh build, I get a dozen or so warnings about un-referenced variables in our core libraries with which we build commercial products.
I like to build without getting compiler warnings, so I took a look, to discover the warnings are caused by the following:
try { // do stuff } catch (Exception ex) { ; }
This elicited a depressed "fuck me". :(
Since this is C#, and our app isn't used in life support or fly-by-wire controls, I think we'd really be better off letting the sucker die horribly instead of slogging on, hoping that things work out OK.
The lead programmer/designer/long-time employee/main author of most of our stuff won't talk to me about it, but I'm pretty sure his attitude is that this shit will never happen, no one using our products has complained, he has lots of real work to do, so STFU.
Gee, I thought it was interesting.
It guessed that I am 38, but I'm 58, so it also put me in a good mood. :)
I'll probably get raked over the coals for even suggesting that there is a problem here, but this snippet that I ran across while trying to find the cause of a core dump irritates me, and did in fact elicit a WTF. The crash was NOT caused by this code:
// find the first '.' char tok[2]; #if defined (WIN32) && !defined (WINCE) sprintf_s(tok, sizeof(tok), "%c", '.'); #else sprintf(tok, "%c", '.'); #endif char* c; c = strstr(pCard->foo, tok);
Why not the following?
char* c = strstr(p->foo, ".");
I know it's not tragic, not a big deal, but I have a hard enough time figuring stuff out without wading thru clutter and crap.
@OzPeter said:
...Seeing that reminded me of this quote:“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
- Brian Kernighan
@dhromed said:
Does the Empty Set contain itself?
No, it does not. The empty set is a set that has no members. A set containing the empty set has at least one member.
IIRC, the empty set, the set containing only the empty set, the set containing only the emtpy set and the set that only contains the emtpy set, etc., is how Whitehead and Russell tried to bridge the gap between set theory and natural numbers in Principia Mathematica.
@SilentRunner said:
Lorne Kates, your use of the F-word does nothing to enhance your credibility or reputation. In fact, it makes you appear to be a 20-something or, worse yet, a teeny-bopper.
You are being ironic, right? You DO know what WTF stands for, don't you??
@havokk said:
If I were in this situation I'd be staying silent in the meeting (right now in my life I need the security of a job) but I'd also be looking for an appropriate shareholder representative to anonymously leak this shit to.
Why would anyone who is not a competent techie and not familiar with the code believe an anonymous leak instead of "genius programmer"?
@snoofle said:
She spent all of the first day at her desk, moaning - in a verrrrrry sexual way.
That is weird, and I could see how it could be distracting. What provokes the moaning, the WTF stuff you report? A pocket rocket vibrator??
@PedanticCurmudgeon said:
@bridget99 said:I'll never understand what purpose wasting 12 years of perfectly good childhood is supposed to serve.It serves a number of purposes, depending on your perspective. For parents, it's free child care. For the students, it's preparation for college, which is preparation for getting a high-paying job (that last part doesn't seem to be working very well lately). For employers, it's a source of workers who will follow orders and do pointless tasks without complaining. For the government, it's indoctrination: the set of ideas that they want people to have is drummed into students' heads basically as soon as they learn to read.
@boomzilla said:
@toon said:@TGV said:the great success the USA has in the imprisonement industry.
Did you know that one percent of the United States population is behind bars right now? The rest of the world's incarceration rates don't even remotely compare to theirs.A testament to the efficiency of our legislators' abilities to make things illegal.
I believe it's more of a testament to Ronald Reagan's War on Drugs and also to Zero Tolerance. The same ol' things are illegal, but the penalties are stiffer.
@dhromed said:
So... just tie the camel.
What goes on between you and a consenting camel is none of my business and, quite frankly, TMI.
@Speakerphone Dude said:
Yeah! Those jokes are Plain Old Silly.
@Mcoder said:
Normaly people choose C++ bcause they can use classes for that. PIMPL is more a C idiom.
Again, I disagree. PIMPL makes plenty of sense if you have classes, want to share a header, but don't want to expose the implementation, or at least very much of it. See ramdom Google hit sayng PIMPL is only useful for C++
@pure said:
I used the PIMPL idiom,
TRWTF.
Not at all. PIMPL is a solid and proven approach for separating implementation from interface in C++. WTF else would you suggest?
I'd been assigned to spec out an interface between two components which will be coded in C++. I used the PIMPL idiom, and because we will have different underlying thingies to deal with, the base implementation class is pure abstract. I put together some code that compiles, with stubbed-out concrete implementations of the abstract class, that would execute. I then sent the code out for comments.
My rookie manager (former lead developer) and I had a conference call with some off-site colleagues who will also be working on the project. We spent a lot of time discussing what we are going to do short term and long term with the thing we are building, then finally started to the subject of the interface.
I noticed that my boss was quickly jotting down pseudo code in his notebook. Without any mention of my stuff, he started with "here is what will work for our interface." Not "what you did sucks" or "we can't really use it" or "it does not address blah blah blah". Instead, we were charging off into back-of-the-envelope land. I was not a happy camper.
Now my boss is mad that I got mad. On the plus side, we did finally start talking about the work I did and some changes to make to it.
Probably TRWTF is my total lack of people skills for dealing with shit like this, but at this late date in my career I don't think any amount of training would keep me from seeing red in this situation. :-(
@Speakerphone Dude said:
I am surprised that StringBuffer is still relevant in Java...
Yup, still relevant, to avoid stupid, useless creation of gazillions of temporary String instances.
@dkf said:
...I've written macros that did computed gotos in C...
Doesn't it feel better to have that off your chest?
@snoofle said:
Forgetting the stupid iteration over the list when the indices being tested are hard wired...
I can't. This will haunt me. It makes me want to hurt someone. Big, big hurt. Maim. Cripple. Torment. Kill, kill, kill, KILL, KILL, KILL!!!
Why not just do something like:
try { double num = Double.parseDouble(thisStr); data.set(Math.round(num)); } catch(NumberFormatException ex) { //log the error. Really. Or maybe even don't catch the exception. }
Not a good idea if you are processing a gazillion of these and the data is mostly ints, so YMMV, but parseDouble can handle int format.
@KattMan said:
With this try-finally blovk, you skip the third line of code and fall right into the finally which does nothing else.
...As I said, you still have a swallowed exception but the code execution has not happened the same. On error resume next is worse, but this is still bad.
This point was made above, but "finally" does not swallow the exception. Instead, as I think we all know but sometimes I just have to say the obvious, it guarantees that a block will be entered whether or not an exception was thrown. Any exceptions still get thrown.
But the "nada" comment after 900 lines of suspense is nonetheless damned anti-climactic.
@snoofle said:
// To whomever inherits this code
//
// I am not a web developer, and have no experience as such.
// They needed this in a crunch and all the web guys were on
// vacation so they forced me to hobble this together. It
// sort of works, although there are plenty of iffy sections
// (noted in code).
//
// Don't try to save it. If you value your sanity, rewrite it.
//
// I'm sorry
So much pain! Now I'll be sad for the rest of the day.
Snoofle, you post some dandies.
@dhromed said:
@Speakerphone Dude said:@Cassidy said:Do you think he was over-apologising then?
Yes.You judge it to be "too much" from a single occurrence?
@Weps said:
Am working on a rather old software component that needs to be ported to another platform. Looking for issues, I stumbled upon this
/*(void) memcpy( is_it_present + block_size, &false, sizeof(bool));*/ /* memcpy does not work, so we set the value of the XXX to false, manually*/ is_it_present[3]=FALSE;Too bad for me that most of the time memcpy does work...
I work with a way senior developer, friend of my boss, who is always saying things like "Perforce isn't working" or "Java is returning the wrong time value" or "MySQL has locked the table"; when he's especially egregious I put the headphones on and crank up music to keep from strangling him.
In the OP, the commented-out line of memcpy() that presumably is what "does not work" is scary. "is_it_present + block_size" is the address just past block_size. Not necessarily wrong, but it could be.
But the craziness is &false. Most likely the preprocessor turns it into something like &(0) -- I'm surprised it compiled.
@Julia said:
<font face="Lucida Console" size="2">
bool tmp = Settings.Foo;if (tmp == !tmp) Debug.Assert(true);
</font>
If that doesn't elicit an out loud WTF, what on earth would?
@darkmattar said:
.. my Outlook screams like a dying cat...
That is so disturbing!
I need a hug...
The major problem I see is that all exceptions are essentially eaten -- error messages are written, but the control flow keeps going on.
TRWTF is having to to put so much more thought into fixing code than the author took in writing it. Your company would be better off if you could somehow discourage this guy from writing any more code, or at least slow him down. Maybe you could pay a thug to break his fingers.
@RTapeLoadingError said:
Well, assuming Windows and Microsoft Outlook as the environment I'd say that in my experience it's not always obvious that you're not connected to the network. You can still log in, seemingly to the domain, as your profile is cached locally; Outlook still opens and lists mails with only a small notification in the bottom corner to say that it can't connect to the Exchange Server and you can create and send emails without error as they just sit in the Outbox.
I guess my configuation options are different from yours: on my XP, if I start Outlook and it cannot establish a connection to the Server I an asked whether I want to work offline; if the network connection drops I get a notification that the server cannot be reached so synching is not possible, and I get an in-your-face warning if I attempt to exit Outlook when there are messages stuck in the outbox
But seriously -- are you really defending the dumb-ass user? This case was so egregious I told my colleagues, and we had a good laugh.
@snoofle said:
...he made the changes in the second level interim generated files and committed them to svn; there was no change in the source to revert.
When queried why he'd change generated files instead of the source, he explained that the changes were in svn so it's ok. When I explained that the next build would wipe out the changes, he explained that they were still in svn, and could be manually retrieved...
You have to admire the developer's confidence that no future changes to the original source will be necessary. When he fixes something, it's fixed!
Talking with the developer or his successor is probably pointless; are there any adults who can be brought into the conversation?
@Hatshepsut said:
Just over-coding.
Not a WTF in sight.
Not a single one.
I'd put it another way: the code stinks, in that it's a chore to determine whether or not it does the right thing. Not a huge problem if you can just call it and trust the results, but a pain in the ass if, e.g., management decides that it's time to add some different strings, perhaps even support different locales.
@serguey123 said:
@morbiuswilters said:You made a lame joke, so I assumed you had eaten the proverbial veal
Ohh, then is the Vegas thing. When I googled the result there were two types of hits: lame comedians and a Godfather youtube clip
I think it's a Borscht Belt thing? Stand-up comedians performing there purportedly would end their routines with "I'll be here all week. Tip the waiters, order the veal!"
But I could have that totally wrong; I grew up in the deep south, a place very different from the north east.
@serguey123 said:
@dhromed said:Game Of Thrones which is pretty good!
I watched the first episode of the first season, it looks that it has good production values but I'll withhold judgement until all seasons are out, however I was mildly annoyed that they chose to skip the first book altogether.
Beg pardon? Game of Thrones is the first book of GRR Martin's "A Song of Ice and Fire" series. And Martin has not yet finished the series. My guess is that there are at least two books to go, which, given Martin's rate of production, means the finale should be on bookshelves by December, 2022.
BSG was well-acted, well-written, and all around really enjoyable if you like extremely dark stories, and if you watched it commercial free. Not to mention the hot chicks it featured: A New Crew in Town
@jpa said:
I hope you refactored it tobtnFoo.Enabled = true ? ((chkSimulateBar.Checked || _isDbConnected) && (txtBletchl.Text.Trim() != "")) : false;in order to raise even more eyebrows in the future.
+1
@Nagesh said:
is this real code or are you just putting interview questions?@rstinejr said:
I love the ternary operator, but not in this case, from a C# app:btnFoo.Enabled = ((chkSimulateBar.Checked || _isDbConnected) && (txtBletchl.Text.Trim() != "")) ? true : false;
It's real. I copied it from code to which I'm adding features, although I changed the variable name roots to "Foo", "Bar", etc., because somehow that seemed like the thing to do.
I love the ternary operator, but not in this case, from a C# app:
btnFoo.Enabled = ((chkSimulateBar.Checked || _isDbConnected) && (txtBletchl.Text.Trim() != "")) ? true : false;
Verbatim:
finally {}
"You never know, we might need to put something here one day..."
Here's a minimally redacted snippet from some C# source for a DLL:
try { result = DoFoo(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); }
I can hear it now: "We're not seeing any errors -- must be a hardware problem."
@morbiuswilters said:
@pjt33 said:@this_code_sucks said:I don't know, most terrorists seem to be pretty stupid. You know how they catch most of them? Yep, the FBI set up traps where they sell terrorists bombs.
The interesting question here is how many of them were actually terrorists before the FBI offered to sell them a bomb, vs just ranting idiots.Well, presumably all of them. If you're in the type of person to buy a bomb, you're probably a terrorist.
I don't buy it. The whole agent provocateur thing stinks, and is something you expect in despotic states, not democracies. I also have reservations when the FBI pats itself on th back for these busts; it sounds more to me that they have caught terrorist wannabes instead of stopped a real threat.
@Speakerphone Dude said:
@C-Octothorpe said:@pjt33 said:List pageRoleList = null;Agreed, this reeks of junior
pageRoleList = GetPageRoleList(pageRole);developercode-monkey.If someone was to declare the list without assigning a value, then in Visual Studio there would be a wiggle under the variable with a warning about using uninitialized variables. Adding
= null
or= String.Empty
like forrolepagefound
will make the wiggle go away.
But if the coder bulls through and writes the next line (the assignment), then the squiggle goes away.
I don't think you can blame this on VisualStudio -- probably it's the violent video games. Or the Nanny State.
@C-Octothorpe said:
... chucking out the old "your not too smart" line in the comments section. :)
Your not too smart.... brother-in-law???
@blakeyrat said:
I can tell you I've tried [Netbeans], and I found something like 6 deal-breaker bugs in the first couple minutes...