Jump to content

  • Log In with Google      Sign In   
  • Create Account

for (score and seven; years_ago; ...

  • You cannot reply to this topic
9 replies to this topic

#1 Cornstalks   Crossbones+   -  Reputation: 6991

Like
4Likes
Like

Posted 24 September 2013 - 05:28 PM

My coworker just showed me this piece of beauty he wrote in a project for a client. It's gloriously horrible. And hilarious.
 
#define years_ago (score < 4)
#define and =
#define our_forefathers (score++)
#define seven 0
int score;
 
- (void)setImage:(UIImage *)image
{
    ...
    for (score and seven; years_ago; our_forefathers) {
        GPUImagePicture * stupidlyNamedClassFromALibraryWithNoRegardForDevelopers = [[GPUImagePicture alloc] initWithImage:image];
        ...
    }
}

[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

Sponsor:

#2 frob   Moderators   -  Reputation: 22796

Like
0Likes
Like

Posted 24 September 2013 - 05:48 PM

... he wrote in a project for a client ...

#define years_ago (score < 4)
#define and =
#define our_forefathers (score++)
#define seven 0

And when they do a code review, he might discover they are a FORMER client.

It might look cute, but in a professional environment stunts like that can easily mean losing your job.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 24 September 2013 - 06:13 PM

And when they do a code review, he might discover they are a FORMER client.

It might look cute, but in a professional environment stunts like that can easily mean losing your job.

The client is actually a programmer himself and did a code review, and inserted the comments:
 
...
// my favorite #define ever.
#define seven 0
int score;
 
- (void)setImage:(UIImage *)image
{
    ...
    // Friggin awesome.
    for (score and seven; years_ago; our_forefathers) {
        ...
    }
}
So I guess it's all good.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#4 frob   Moderators   -  Reputation: 22796

Like
0Likes
Like

Posted 24 September 2013 - 08:02 PM

Very lucky for him it didn't turn out different.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#5 Sik_the_hedgehog   Crossbones+   -  Reputation: 1836

Like
0Likes
Like

Posted 24 September 2013 - 09:01 PM

Bonus: and is actually a keyword in C++ (inherited from iso646.h then made part of the language), so that macro is effectively changing the language itself. Can't get worse than this.

 

Reminds me of somebody who found long long ago in a file, except of course in that case it was something perfectly acceptable that happened to fit perfectly (long long is a built-in type, and ago is a variable name). No cheating needed there.


Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

#6 Migi0027   Crossbones+   -  Reputation: 2136

Like
0Likes
Like

Posted 29 September 2013 - 07:42 AM

I, I don't even know what to say...


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!

#7 stupid_programmer   Members   -  Reputation: 1241

Like
0Likes
Like

Posted 29 September 2013 - 01:12 PM

Bonus: and is actually a keyword in C++ (inherited from iso646.h then made part of the language), so that macro is effectively changing the language itself. Can't get worse than this.

 

Reminds me of somebody who found long long ago in a file, except of course in that case it was something perfectly acceptable that happened to fit perfectly (long long is a built-in type, and ago is a variable name). No cheating needed there.

 

The code is Objective-C so no worries about it being a keyword.  But it is Objective-C which is a coding horror of its own.  I shudder the days I need to work on iOS stuff at work.


Edited by stupid_programmer, 29 September 2013 - 01:13 PM.


#8 DekuTree64   Members   -  Reputation: 986

Like
4Likes
Like

Posted 29 September 2013 - 04:37 PM

laugh.png That is gloriously horrible.

 

How about a #define-free loop?

for(; score & 7; years(ago)) { ... }


#9 dsm1891   Crossbones+   -  Reputation: 1569

Like
0Likes
Like

Posted 08 October 2013 - 03:26 AM

just broke down laughing... lol



#10 iAmCodeMonkey   Members   -  Reputation: 215

Like
0Likes
Like

Posted 06 November 2013 - 10:47 PM

Wow lol

 

As funny as that was, that is the SOLE reason why I never use macros.







PARTNERS