Comment On Coded Smorgasbord: The Pilot Episode

It's time for a new series: The Coded Smorgasbord. Inspired by the Pop-up Potpourri, the examples presented here aren't necessarily "bad" code nor do they imply the miserable failure that we're all used to reading here. Like previous "bunch o' code" articles, the examples are more-or-less fun snippets of code like ones that we've all written at one time or another. Enjoy! [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:48 • by ammoQ
Alex Papadimoulis:

Talk about customer service! Josh's company really makes sure that Customer #7742's order date is ... well ... Customer #7742's order date ...

If .Fields("CUST_NUM") = "7742" Then
dtmOrderPlaced = dtmOrderPlaced
End If

 

This one is called "poor man's conditional breakpoint".

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:49 • by Anonymous
93782 in reply to 93781
great idea - though this does take away some sidebar fodder.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:50 • by savar

yayyyyy!!

code WTFs -- lots of them!

i guess i'll have to stop complaining. what am i going to do with my time now?

 

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:53 • by Bradlegar the Hobbit
Alex Papadimoulis:
private final static String twentyspaces = "                         ";

Shouldn't that be twentySomethingSpaces?

 

captcha: awesomeness. Just like today's WTF!

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:58 • by Yuriy
93785 in reply to 93784
Anonymous:
Alex Papadimoulis:
private final static String twentyspaces = "                         ";

Shouldn't that be twentySomethingSpaces?

 

captcha: awesomeness. Just like today's WTF!

 

twentyFiveSpaces.  I'm guessing the requirements changed to require more spaces, but they didn't feel like changing the variable name everywhere it's used.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 13:58 • by Volmarias
93786 in reply to 93784
Ah, brillant. It's been a while since we've had a delightful smorgasbord of code snippets. These are all fortunately more hillarious than horrid.

I particularly like how Sunday is Admin day. I suppose they decided that it would be more empowering than Casual Fridays.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:00 • by Karl von L.
Alex Papadimoulis:
If .Fields("CUST_NUM") = "7742" Then
dtmOrderPlaced = dtmOrderPlaced
End If

This looks to me like the developer just needed a place to stick a breakpoint so he could start stepping through the code when it got to customer #7742, so he could figure out why it was failing for that customer. At least, that's why *I've* written code like this.
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:02 • by BradC
Alex Papadimoulis:

I'm sure a lot of you would have mocked Josh's collegue for having a constant named COMMA. Ha! Who's laughing now?

#define COMMA "|"

Beautiful in its simple WTF'ery.

Probably this should be something like

#define DELIMITER "|"

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:02 • by merreborn

Alex Papadimoulis:
lSend = IIf(lSend = True, True, False)

In a loosely typed language, this could actually have an effect similar to

ISend = (bool) ISend

no? e.g., if ISend is actually (int)14, the 'wtf' line of code would convert it to a (bool)true, correct?

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:04 • by el jaybird
Alex Papadimoulis:
// This instance of OPParcelObj is owned by an instance of 

// OPParcelArray that is associated with an instance of
// OPCustThread which owns an instance of the parcel
// processor which is the processor needed to process
// this parcel.

 ... which is part of the house that Jack built?

(Captcha: Chocobot. Mmmm....)

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:06 • by Colin McGuigan
MakeCum reminds me of one of my earlier efforts, when I had to work on a fund accrual generation system, or the FAG system, which consisted of FAG customers, FAG products, FAG rates, etc...

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:06 • by Ghost Ware Wizard

My Favorite:

 if (cust = "Wal-Mart")

order date := dateFromEDI

ship date := dateFromEDI - (dayof week(today)) + day of week

end if

so when you get to day 1, usually monday what happens?

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:09 • by R.Flowers
Alex Papadimoulis:

F.S. noticed that Australian airline JetStar is very careful about ensuring visitors are sent to the proper page ...



if ((version=="NS") || (version=="IE")) 

{

if (version=="NS")

/* NS URL */

window.location="/skylights/cgi-bin/skylights.cgi";

else

/* IE URL */

window.location="/skylights/cgi-bin/skylights.cgi";

}

else

/* OTHER URL */

window.location="/skylights/cgi-bin/skylights.cgi";


Let's be kind and assume the missing comment is something like:


  /* I'll get back to this later - in a hurry! */

 


Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:10 • by Anonymous
Alex Papadimoulis:
Matt Spicer was in the middle of a VB6 to C# conversion projection and stumbled across this next snippet. He decided to not bring this line of code to the new project ...
lSend = IIf(lSend = True, True, False)
Now, now, that's perfectly explainable.  You've got to account for if ISend == FileNotFound when you're converting from "robust" Boolean to "boring" Boolean values.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:13 • by Wyatt Earp
93797 in reply to 93781
ammoQ:
Alex Papadimoulis:

Talk about customer service! Josh's company really makes sure that Customer #7742's order date is ... well ... Customer #7742's order date ...

If .Fields("CUST_NUM") = "7742" Then
dtmOrderPlaced = dtmOrderPlaced
End If

 

This one is called "poor man's conditional breakpoint".

 Placing a non-conditional breakpoint under the if is significantly faster than placing a conditional breakpoint in the code if this is in a loop that gets executed a bunch of times (at least this was true in VS.NET 2003).

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:16 • by firedup
93798 in reply to 93796
Anonymous:
Alex Papadimoulis:
Matt Spicer was in the middle of a VB6 to C# conversion projection and stumbled across this next snippet. He decided to not bring this line of code to the new project ...
lSend = IIf(lSend = True, True, False)
Now, now, that's perfectly explainable. You've got to account for if ISend == FileNotFound when you're converting from "robust" Boolean to "boring" Boolean values.

Nice!

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:20 • by firedup
93800 in reply to 93788
BradC:
Alex Papadimoulis:

I'm sure a lot of you would have mocked Josh's collegue for having a constant named COMMA. Ha! Who's laughing now?

#define COMMA "|"

Beautiful in its simple WTF'ery.

Probably this should be something like

#define DELIMITER "|"

A few projects back I worked with a girl 3 months out of school. We had some coding style rules, one of which was 'descriptive variable names'. Instead of, as you suggest, "DELIMITER", she used something like: "THE_CHARACTER_THAT_SEPARATES_FIELDS_IN_THE_PARAMETER_STRING".

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:21 • by anonymous

Sunday is admin day is pure genius.

I can't believe I haven't seen that anywhere, before; you can bet I'm going to start using it.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:24 • by Andreas
Please try to keep Coded Smorgasbord submissions small and no more than eight lines of readable code.
So as long as the code is not readable, any length is ok... 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:46 • by pjsson
93806 in reply to 93786

Volmarias:
I particularly like how Sunday is Admin day. I suppose they decided that it would be more empowering than Casual Fridays.

I guess no regular users will use the application on Sundays, so it is safe to assume that anyone using the application on a Sunday is an admin. At least until some user figures out if he changes the date of the PC clock to Sunday then you will get full admin privileges.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:47 • by science_gone_bad
93807 in reply to 93792

Or even better, the system I worked on named by the Marketing Wonks:

CRP

 Had us laughing for an hour since we definitely had the fastest CRP around

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:51 • by Jan
Alex Papadimoulis:
lSend = IIf(lSend = True, True, False) 

Of course, this is useful.

Imagine what would happen if the value of lSend equals FileNotFound!
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:51 • by Dark
93809 in reply to 93789
merreborn:

Alex Papadimoulis:
lSend = IIf(lSend = True, True, False)

In a loosely typed language, this could actually have an effect similar to

ISend = (bool) ISend

no? e.g., if ISend is actually (int)14, the 'wtf' line of code would convert it to a (bool)true, correct?

See, this is *why* such code is wtf :)

If ISend is actually (int) 14, then that line of code would convert it to a (bool)false. Because it compares ISend = True, instead of just using ISend as a conditional. And they're not going to be equal.

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 14:52 • by marvin_rabbit
93810 in reply to 93784
Anonymous:
Alex Papadimoulis:
private final static String twentyspaces = "                         ";

Shouldn't that be twentySomethingSpaces?

 

I'm guessing that the extra spaces were from Alex's anonymisation.  We wouldn't want top-secret company info leaking out.
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:01 • by rgs
Alex Papadimoulis:

I'm sure a lot of you would have mocked Josh's collegue for having a constant named COMMA. Ha! Who's laughing now?

#define COMMA "|" 

 

Hmmm That's not soooo bad, I mean:

   Boss: Write a module that handles .csv files (comma separated values)

   Programmer:  Ok

   [A few days later]

   Boss: Ok, here is a .csv file to try your module:

   File: data;moredata;another data; etc

   Programmer: .....

   [More days later]

   Boss: the client sent this file, almost like the ones we'll use in production

   Second File: data-moredata-another data- etc.

And so on... 

The easiest solution is to #define COMMA

 Now I dare all of you to tellme that this never ever happened to you...

 

Captcha: captcha: captcha: captcha.............
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:12 • by Rank Amateur
Alex Papadimoulis:

F.S. noticed that Australian airline JetStar is very careful about ensuring visitors are sent to the proper page ...

if ((version=="NS") || (version=="IE")) 

{
if (version=="NS")
/* NS URL */
window.location="/skylights/cgi-bin/skylights.cgi";
else
/* IE URL */
window.location="/skylights/cgi-bin/skylights.cgi";
}
else
/* OTHER URL */
window.location="/skylights/cgi-bin/skylights.cgi";
I'm outraged. What about Opera? You can't have Opera browsers going to 
/skylights/cgi-bin/skylights.cgi! Clearly you have to direct them to 
/skylights/cgi-bin/skylights.cgi! This is browser discrimination!
--Rank

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:17 • by Botia
How many of you counted the spaces?  :)

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:22 • by cconroy
Alex Papadimoulis:

For those of you with a maturity level greater than "14 years old", this next snippet probably won't be for you. Thankfully, Brian Samson isn't one of those people ..

public class MakeCum {

public static void main(String[] args) {
...
CLArgParser clap = new CLArgParser(clargs);

boolean err = clap.doStdArgs(args);

if (err) {
System.out.println("Usage: MakeCum ");
System.out.println(clap.getStdArgsDescription());
return;
}
...}

Ah
yes, that class has it all: MakeCum, STD Arguments, and even the Clap
makes an appearance! And who would have thought a class that did
nothing but "convert a set of binned counts to cumulative counts" could
be so fun.

Can... hardly... keep... a...
straight... face...  (All that's missing is a "catch
(ValueTransitionException valTrEx) {}" block; then I would have lost
it.)

I used to try to avoid the "cum" abbreviation whenever possible,
but app I'm currently working on has "cumQty" variables all over the
place, so I've gotten pretty desensitized to it.  Now I have much
more stamina tolerance for its usage.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:23 • by anonymous
93818 in reply to 93806
pjsson:

Volmarias:
I particularly like how Sunday is Admin day. I suppose they decided that it would be more empowering than Casual Fridays.

I guess no regular users will use the application on Sundays, so it is safe to assume that anyone using the application on a Sunday is an admin. At least until some user figures out if he changes the date of the PC clock to Sunday then you will get full admin privileges.

 I interpret it as, anyone working on Sunday must need to get work done, and doesn't have time to screw around with potential permission issues, or getting hold of an admin to grant him permissions. 

(Our non-admin users do not have the privilege to change the clock, so, we don't have to worry about the problem you describe.  We only have to worry about them coming in on Sundays.)

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:26 • by Botia
93820 in reply to 93816
Man, it's good to see some nice code WTF's!  This is the stuff that just makes your day.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:33 • by Reed
93821 in reply to 93788

On a really basic intellectual level, programming is about coming up with elegant ways to describe things that happen.  Remember, always name it what it's *for*, and *why it exists* not what exactly it does! Otherwise, why bother with any kind of structured high-level programming?
 

Reed 

 

BradC:
Alex Papadimoulis:

I'm sure a lot of you would have mocked Josh's collegue for having a constant named COMMA. Ha! Who's laughing now?

#define COMMA "|"

Beautiful in its simple WTF'ery.

Probably this should be something like

#define DELIMITER "|"



Pro

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:34 • by Rob
93822 in reply to 93807

I always wanted to create a help desk system called "My Pants". 

Support: "Hmm, I've never heard of that. Let me search my pants and see what I can find."

Support:  "I'm sorry, My Pants is down, so I can't answer your question."

Support:  "I seem to recall seeing something about that in My Pants."

 The 14 year old humor possibilities are endless!

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:46 • by Jeff S
93824 in reply to 93801
Anonymous:

Sunday is admin day is pure genius.

I can't believe I haven't seen that anywhere, before; you can bet I'm going to start using it.

Don't forget what the Bible says ... "On the 7th day, the hackers shall rest."

Bravo, Alex!  Best post in a long, long time .... thanks for giving me some good laughs on a busy Friday afternoon ! 

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:56 • by Jojosh_the_Pi
Alex Papadimoulis:
int doctrackId = Convert.ToInt32("0");  //wtf!!


Maybe the programmer was concerned the int would be initialized with 64 bits, so he used this to try to specify a 32 bit integer, thus conserving memory.

How many comments the last few months have speculated The Daily WTF was running out of material?  Ha!

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:57 • by drdamour
93828 in reply to 93809
Anonymous:
merreborn:

Alex Papadimoulis:
lSend = IIf(lSend = True, True, False)

In a loosely typed language, this could actually have an effect similar to

ISend = (bool) ISend

no? e.g., if ISend is actually (int)14, the 'wtf' line of code would convert it to a (bool)true, correct?

See, this is *why* such code is wtf :)

If ISend is actually (int) 14, then that line of code would convert it to a (bool)false. Because it compares ISend = True, instead of just using ISend as a conditional. And they're not going to be equal.

 This is all language dependant, in VB6 some very strange things happen with implicit conversions:

    Dim i As Integer
    i = 14
    Dim x1, x2, x3 As Boolean
    x1 = (i = True)
    x2 = (True = i)
    x3 = i

x1 and x2 will be false, but x3 is true?

but that really is the WTF because that iif is stil useless, could have just been

lSend = (lSend = True)

    Dim i As Integer
    i = 14
    i = (i = True)

i will be 0 in VB6, so it can be passed to a function taht only excepts 0 or -1, at least that's my guess to the reason

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 15:58 • by ptomblin
"Sunday is admin day" reminds me of when I worked for a large Geographic Information System company.  We had a password backdoor for the benefit of the "specialists" that we'd send out to customer sites to help them with their setup and customization.  Originally, the secret password was the day of the week spelt backwards (ie "yadnus").  But our specialists couldn't get that right even if they wrote the rule on their hands, so we had to change it to a single asterisk.    The specialists actually managed to remember that.  Unfortunately they taught it to all the customers, so in 6 years of working there I never saw a customer using a real password.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:00 • by ptomblin
93830 in reply to 93817
cconroy:

I used to try to avoid the "cum" abbreviation whenever possible,
but app I'm currently working on has "cumQty" variables all over the
place, so I've gotten pretty desensitized to it.  Now I have much
more stamina tolerance for its usage.

 

According to a lot of spam I get, there is help available if your cumQty isn't high enough. 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:04 • by foobish

"The Pilot Episode" - Is that a reference to the first ever episode of The X Files?

captcha: poprocks - The first ever candy that rocked.
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:09 • by Chaz

14 year old humour - I work with a database called "MasterData". Not that funny if you are Kiwi like my colleagues, as they pronounce data the American way (First syllable rhymes with bar). However, I'm from the UK and for me it rhymes with day. Try saying it my way, out loud...

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:10 • by ParkinT

What?

No XML ?!

<g>

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:12 • by ParkinT
93835 in reply to 93832
Anonymous:

14 year old humour - I work with a database called "MasterData". Not that funny if you are Kiwi like my colleagues, as they pronounce data the American way (First syllable rhymes with bar). However, I'm from the UK and for me it rhymes with day. Try saying it my way, out loud...

I imagine it could be worse.

Someone from New England who often adds nonexistent "r" to any word ending in a vowel sound (like idear for idea) !

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:14 • by a.non
93836 in reply to 93828
drdamour:
Anonymous:
merreborn:

Alex Papadimoulis:
lSend = IIf(lSend = True, True, False)

In a loosely typed language, this could actually have an effect similar to

ISend = (bool) ISend

no? e.g., if ISend is actually (int)14, the 'wtf' line of code would convert it to a (bool)true, correct?

See, this is *why* such code is wtf :)

If ISend is actually (int) 14, then that line of code would convert it to a (bool)false. Because it compares ISend = True, instead of just using ISend as a conditional. And they're not going to be equal.

 This is all language dependant, in VB6 some very strange things happen with implicit conversions:

    Dim i As Integer
    i = 14
    Dim x1, x2, x3 As Boolean
    x1 = (i = True)
    x2 = (True = i)
    x3 = i

x1 and x2 will be false, but x3 is true?

but that really is the WTF because that iif is stil useless, could have just been

lSend = (lSend = True)

    Dim i As Integer
    i = 14
    i = (i = True)

i will be 0 in VB6, so it can be passed to a function taht only excepts 0 or -1, at least that's my guess to the reason

 

lucky you assigned in he order you id, seeing as you declared 2 variants and 1 boolean:


    x1 = (i = True)
    x3 = (True = i)
    x2 = i

x2 would have been 14

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:19 • by Matt S
93837 in reply to 93789
This was actually a boolean variable, which defaults to false in VB6.  I think the original intent was to change it to true if it wasn't already, but lSend = True would have actually worked.

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:37 • by Oliver Klozoff
93840 in reply to 93832
Anonymous:

14 year old humour - I work with a database called "MasterData". Not that funny if you are Kiwi like my colleagues, as they pronounce data the American way (First syllable rhymes with bar). However, I'm from the UK and for me it rhymes with day. Try saying it my way, out loud...

 What Americans are you talking about? I've always pronounced it "day tuh". 
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:44 • by BradC
93843 in reply to 93822
Anonymous:

I always wanted to create a help desk system called "My Pants". 

Support: "Hmm, I've never heard of that. Let me search my pants and see what I can find."

Support:  "I'm sorry, My Pants is down, so I can't answer your question."

Support:  "I seem to recall seeing something about that in My Pants."

 The 14 year old humor possibilities are endless!

Lol, nice.

Support: "Please hold. Sysadmin Julia currently has My Pants down for servicing."

Support: "I'm sorry, My Pants is a little slow today..."

Support: "I'm sorry, I can't seem to find that in My Pants."

 

 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:49 • by phsiii

Re the JetStar example: I don't have a problem with that -- it's expandable/updatable for the future.  Harmless at worst; MIPS are cheap.  Still funny, though...

Captcha: stfu
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:52 • by Solo
93847 in reply to 93787
Anonymous:
Alex Papadimoulis:
If .Fields("CUST_NUM") = "7742" Then
dtmOrderPlaced = dtmOrderPlaced
End If

This looks to me like the developer just needed a place to stick a breakpoint so he could start stepping through the code when it got to customer #7742, so he could figure out why it was failing for that customer. At least, that's why *I've* written code like this.
 

I do it too, but I don't let anyone know. I clean up after myself. The next thing you know, another drone is poking through the files checked in with my name on it looking for that kind of thing :)

captcha: random. As in random code generation.
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:53 • by Solo
93848 in reply to 93788
BradC:
Alex Papadimoulis:

I'm sure a lot of you would have mocked Josh's collegue for having a constant named COMMA. Ha! Who's laughing now?

#define COMMA "|"

Beautiful in its simple WTF'ery.

Probably this should be something like

#define DELIMITER "|"

#define PIPE ","
 

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:56 • by Anonymous
93849 in reply to 93843

BradC:
Support: "Please hold. Sysadmin Julia currently has My Pants down for servicing."

That's almost /too/ good.  Of course, it'd be just the opposite if the following were to happen:

"I'm sorry, there seems to be a problem with My Pants today.  We had to bring it down, we've been having almost non-stop core dumps this moring."

Re: Coded Smorgasbord: The Pilot Episode

2006-09-29 16:59 • by John Meikenson
93850 in reply to 93781
That is exactly what that is. It should have been removed during a peer review (HA!), but it's definitely not a WTF.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment