Comment On Representative Line: Tetricosanary Logic

Good news, everyone: it's time for a new series! Technically, this is not the first time that I've presented a Representative Line: a single line of code from a large application that somehow manages to provide an almost endless insight into the pain that its maintainers face each day. However, going back and renaming the old articles is a bit of a hassle, so I'll just pretend this is the first episode. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Representative Line: Tetricosanary Logic

2006-11-14 13:59 • by sinistral
No doubt return_true_24() not only returns true, it aborts if it thinks that you're a terrorist seeking to take control of the US government.

Re: Representative Line: Tetricosanary Logic

2006-11-14 13:59 • by Marak

What's wrong with this?

 I write functions all the time that return true.

 

 

captcha: tps         mmmmmmmmm yeaaaaaaaaaaaah

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:04 • by Christophe
Of course it makes perfect sense. You need a family of functions to reflect varying degrees of 'truthiness'.

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:05 • by OMG
101622 in reply to 101615
So, what's new?
enum Bool { 

TRUE,
TRUE_1,
TRUE_2,
// ... TRUE_23,
TRUE_24,
FALSE,
FILE_NOT_FOUND
};

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:06 • by dpm
101623 in reply to 101615

I call dibs on writing the  return_true_42() function.



ok

dpm

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:16 • by JL

Alex Papadimoulis:
There are actually twenty-three other return_true functions in the system, each one doing something slightly different and, ironically, often returning false.

I'd be fascinated to see some examples -- ideally, three or more.  Given the function's only purpose is to return a boolean value, I wonder what "slightly different" actions it could be performing...  Some nasty side-effects, perhaps?  Or maybe the code contains "#define bool int"?

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:25 • by Autonuke
101635 in reply to 101623
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:27 • by LordVetinari

The WTF for me is the Symantec add in the RSS feed that says 'Enterprise security software that gets to threats before they get to you'.

Two things:

  • Enterprise... Not a good word to use on this forum.
  • 'before they get to you'... are they talking about Symantec or the threats?

 

wtFFtw 

captcha: awesomeness

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:27 • by Erzengel
101637 in reply to 101615
Anonymous:

What's wrong with this?

 I write functions all the time that return true.

(I hope you're joking) There's a differance between a function with a meaningful name that returns true, and a function whose stated purpose is to return true, and yet might not. One should give such a function a meaningful name so that maintainers will know what's really happening in the function:

//Note: WTF's are intentionally preserved: Feel free to count them.

bool return_true88()
{
    if(return_true12() && return_true5()) return true;
    else if(return_true19())
    {
        FILE* junk = fopen("config.txt", "r");
        char tmp[256];
        fread(tmp, 1, 256, junk);
        it(tmp[0] == 'a') return true;
    }
    return false;
}

 As you can see, you really don't know what's happening in 12, 5, and 19. All you know is that 88 tends to open a file, forget to close it, and contains no error checking. imagine if these had meaningful names, like CheckRegistry, CheckCommandVars, and ConfigExists.

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:30 • by Corporate Cog
Alex Papadimoulis:

For clarification, the "_24" suffix is not some bizarre homage to the author's favorite television show. It's ordinal; there are actually twenty-three other return_true functions in the system, each one doing something slightly different and, ironically, often returning false.

Proof positive that all maintenance programmers (like myself) are suckers. 

Captcha = awesomeness.  I wish.
 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:31 • by OMG
101641 in reply to 101635

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:34 • by Jason
101643 in reply to 101641
Anonymous:

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

 

This Anonymous fails in a most spectacular way. Congratulations in showing your literary ignorance :P. 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:35 • by Sarusa
101644 in reply to 101641

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

return (bool) ( return_true_6() * return_true_9() );


Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

 

http://en.wikipedia.org/wiki/The_Answer_to_Life,_the_Universe,_and_Everything

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:35 • by mav

(rampant speculation)

maybe the function looked like this:

bool return_true_24()
{

   static int truthiness = 24;
   return (truthiness) ? (truthiness-- != 0) : false;
}


 

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:39 • by narrator
101648 in reply to 101641

The number 42 refers to The Answer to The Ultimate Question of Life, The Universe, and Everything from The Hitchhiker's Guide to the Galaxy by Douglas Adams. The ultimate question turned out to be 'what is six times nine', also from Adams' series.

So... intentional, but not a WTF.
 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:40 • by marvin_rabbit
101650 in reply to 101641
Anonymous:

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

Nope.  Yours is the WTF for now knowing The Hitchhikers Guide Trilogy lore. 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:40 • by Zap
101651 in reply to 101641
Anonymous:

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

 

6*7 = 42 if you use a tridecimal system.

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:42 • by Jason
101653 in reply to 101651

and oddly enough, 6 * 9 = 42 in base 13.

 

Captcha: knowhutimean  No, I don't think I do.
 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:46 • by Zap
101655 in reply to 101651
Anonymous:
Anonymous:

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

 

6*7 = 42 if you use a tridecimal system.

 

actually, that should be "6*9" instead of "6*7". 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:47 • by emurphy
101656 in reply to 101653

"I may be a pretty sad person, but I don't make jokes in base 13."

--Douglas Adams

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:49 • by PlasmaB
101657 in reply to 101637

The only circumstances under which i would write a function like this is if i were writing a proc/function who's implementation has yet to be completed *and* i wish to test the rest of the system in isolation.

This sort of thing should, of course, be FIXME'd to death! and never reach test, let alone live!

The WTF is that there are coders out there that do this!!! Mind you don't trip over your spurs boys!!!

 

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 14:59 • by Jason
101661 in reply to 101656
emurphy:

"I may be a pretty sad person, but I don't make jokes in base 13."

--Douglas Adams

 

 

Which is why I said 'oddly enough'...

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:04 • by pbounaix
it doesnt get better than this.... truly a "Representative Line" :D

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:06 • by nuclear_eclipse
101663 in reply to 101655
The *real* WTF is that this article has turned into nothing but a pedantic HHGTTG festival....

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:17 • by PlasmaB
101667 in reply to 101663

>The *real* WTF is that this article has turned into nothing but a pedantic HHGTTG festival....

agreed! lets have some *real* WTFs please!

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:25 • by newfweiler
101670 in reply to 101667
Anonymous:

>The *real* WTF is that this article has turned into nothing but a pedantic HHGTTG festival....

agreed! lets have some *real* WTFs please!

I once quoted "Resistance is useless!" and was chided "Resistance is FUTILE!  Get it right!".  Evidently I was in the middle of a pendantic something else festival.

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:27 • by Jon W
Seems to me as if these functions were actually reverse-engineered from somewhere. That's how you get to names like these. That, or a massive amount of scripted program transformation...

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:31 • by Proud To Be Junior
101674 in reply to 101670

The ultimate WTF method declaration we had at my last place from one of our Senior Software Developers was a method in java declared as:

 public List fetchSameButDifferent(List other);

 

I can't remember what it did (or tried to do), but I will never forget that name...

 

Ooh! Ooh! I found it!

2006-11-14 15:38 • by Benanov

The REAL WTF is that they don't start numbering from zero!

*ba dum bum pish*

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:44 • by bgodot
101681 in reply to 101670
newfweiler:
Anonymous:

>The *real* WTF is that this article has turned into nothing but a pedantic HHGTTG festival....

agreed! lets have some *real* WTFs please!

I once quoted "Resistance is useless!" and was chided "Resistance is FUTILE!  Get it right!".  Evidently I was in the middle of a pendantic something else festival.

 Resistance is Volts over Amperes.

Re: Representative Line: Tetricosanary Logic

2006-11-14 15:51 • by badpazzword
101685 in reply to 101655
Since we are in subject of WTFs and 42: (Source)

#include <stdio.h>
#define SIX 1 + 5
#define NINE 8 + 1
int main() {
  printf( "The real meaning of life: %d\n", SIX * NINE );
  return( 0 );
}

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:07 • by Matthew
101693 in reply to 101685

Heh. That's clever. Thanks for sharing. :)

Captcha: 1337

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:08 • by bruzie
101696 in reply to 101650
marvin_rabbit:
Anonymous:

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

Perhaps you meant return_true_6() * return_true_7(), or was that an intentional wtf?

Nope.  Yours is the WTF for now knowing The Hitchhikers Guide Trilogy lore. 

 But how do you know that the question isn't 6 x 7? The computer that was calculating the great question (Earth) was compromised by the addition of the Golgafrinchams 2 million years before readout. Therefore the question was tainted - 6 x 9 = 42. The question was supposed to be calculated by the humans descended from the cavemen, not the telephone sanitisers.

We don't know (and neither did DNA) what the true question was.
 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:20 • by jkaiser
101699 in reply to 101635

was beat to it....

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:21 • by savar
101700 in reply to 101622
The "real WTF" is that it isn't consolidated into one function:
return_true(int truthiness_level) {

switch (truthiness_level) {
case 1:
// do whatever it is that
// those crazy cats are doing...perhaps:
return true && false || true ^ false || true -1 & sqrt(false);
case 2:
...
case 24:
return k_shoot_myself_in_the head;
}
}

Hmmm after rereading this I think I should have added explicit sarcasm tags. Or are they implied for all posts on TDWTF?

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:25 • by savar
101701 in reply to 101685

Anonymous:
Since we are in subject of WTFs and 42: (Source)

#include <stdio.h>
#define SIX 1 + 5
#define NINE 8 + 1
int main() {
  printf( "The real meaning of life: %d\n", SIX * NINE );
  return( 0 );
}

 

Thanks for the link...I never read an analysis of a C program in Italian before.

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  

}

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  nValue

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  nValue

=

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  nValue 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  nValue  =

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:35 • by Ghost Ware Wizard

<wtf/>

what about:

public int GetInt()

{

int  nValue  = 0;

return nValue;

}

and then having all of your developers use GetInt when they need an local variable.

 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:37 • by Ghost Ware Wizard
AAAAAAAAAAAAAAAAAA sorry people

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:38 • by Anonymous
101709 in reply to 101685

Anonymous:
Since we are in subject of WTFs and 42: (Source)

#include <stdio.h>
#define SIX 1 + 5
#define NINE 8 + 1
int main() {
  printf( "The real meaning of life: %d\n", SIX * NINE );
  return( 0 );
}


That's nice, you should put that on the English version of Wikipedia.
(I don't understand Italian, so I couldn't translate the explaining text for the code myself)

captcha: is already in my autocompletion list ;-) 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:38 • by sf
101710 in reply to 101635

Autonuke:
dpm:
I call dibs on writing the  return_true_42() function.

ok
dpm


:-)

return (bool) ( return_true_6() * return_true_9() );

 I prefer:

if ( (bool) ( return_true_6() * return_true_9() ) == TRUE)

     return TRUE;

else

     return FALSE; 

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:43 • by Hans
101713 in reply to 101670

I hope you corrected the misguided pedant. The correct line is indeed "Resistance is useless!", as can be heard on track 16 of the CD edition. Oh, and for more information on this vital subject, please refer to this article.












:-)

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:45 • by GoatCheez
the TRUE wtf is that it's not a tri-state! Bheh.... I was going to write something about how I want to wrap my hands around the whole dev team's necks including  the project managers, but bleck... I've accepted the fact that craptastic shit like this is an everyday occurance. I only hope that I'm never on such a team...

Re: Representative Line: Tetricosanary Logic

2006-11-14 16:49 • by Whiskey Tango Foxtrot? Over.
101716 in reply to 101648
Anonymous:

The number 42 refers to The Answer to The Ultimate Question of Life, The Universe, and Everything from The Hitchhiker's Guide to the Galaxy by Douglas Adams. The ultimate question turned out to be 'what is six times nine', also from Adams' series.

So... intentional, but not a WTF.
 

 Being pedantic about HGttG is entirely fun -- especially since I've been re-reading the series recently -- so I'm gonna go ahead and be pedantic and say:

 "Yeah, um, we never actually find out what the ultimate question is in the book, that part where Arthur pulls letters out of a hat is just a joke. Arthur got it, you should too. Also, the correct quote is 'what do you get when you multiply six by nine'."

 

Ok, I'm done. :D
 

Re: Representative Line: Tetricosanary Logic

2006-11-14 17:05 • by Eam
101721 in reply to 101716

bool return_true_24()

{

  return Convert.ToBoolean("They have my daughter".ToString());

Re: Representative Line: Tetricosanary Logic

2006-11-14 17:09 • by Otto
101722 in reply to 101716
Whiskey Tango Foxtrot? Over.:

 "Yeah, um, we never actually find out what the ultimate question is in the book, that part where Arthur pulls letters out of a hat is just a joke. Arthur got it, you should too. Also, the correct quote is 'what do you get when you multiply six by nine'."

Agreed. DNA expanded the joke to actually make more sense in the book version, where Ford notes that it's probably the wrong question, or a variation on the right one (before they pull out the letters). Having it turn out to be a variation on the wrong one was the humorous bit, which most people miss anyway.

In the radio series it is much less clear, I grant you. The gag there is more along the lines of it indeed being the correct question, it simply turns out that the universe itself was wrong.

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment