Jump to content

  • Log In with Google      Sign In   
  • Create Account

New forum - Coding Horrors

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

#1 Michael Tanczos   Senior Staff   -  Reputation: 5451

Like
3Likes
Like

Posted 25 February 2013 - 12:31 PM

I'm just popping in a new post here for this forum we're kicking off.   The description for this forum is simply this:

 

Discuss software design issues, quirky things you've found, asshat approaches to problems, shitty code your co-workers wrote, shitty code you yourself wrote and wondered what you were thinking, elegant problem solutions (to flip things around), design patterns, "hey look I can write a compiler with one line of code because I'm so clever" type stuff

 

This is a for-fun forum where you can pretty much discuss software design issues including such as:

 

  • Why every programmer should use singletons
  • Why OpenGL is far superior to DirectX
  • Using Goto is perfectly fine
  • Why professional programmers who only code during their day jobs will never be as good as those who code outside of work
  • Why commenting EVERY SINGLE LINE OF CODE is important   // add x to y and store inside of sum

 

 

   ....
   // tCount keeps showing up negative here for some reason..  it should never be negative
 
   tCount = sqrt(tCount*tCount);  // Fixed!
 

 

It is for posting pieces of code that we can all look back on and laugh about.   Code samples are also appreciated.. we love code.   We also love related comics as well.

 

 

computer_problems.png

 

 

 

Glob pattern matcher anyone (*)?

 

main(int c,char**v){return!m(v[1],v[2]);}m(char*s,char*t){return*t-42?*s?63==*t|*s==*t&&m(s+1,t+1):!*t:m(s,t+1)||*s&&m(s+1,t);}

 

Share your frustrations.. share your triumphs.. Let the games begin.


Edited by Michael Tanczos, 25 February 2013 - 12:32 PM.


Sponsor:

#2 Tournicoti   Prime Members   -  Reputation: 684

Like
0Likes
Like

Posted 25 February 2013 - 02:15 PM

if (x^2>0) then patato else tomato

is it supid enough for this new forum ? ^^

Sorry =)

 

This is stupid because the answer is always potatoph34r.png

Of course you can replace patato with tomato. If you prefer tomato. Do you like patato ?


Edited by Tournicoti, 26 February 2013 - 07:51 AM.


#3 Cornstalks   Crossbones+   -  Reputation: 6991

Like
0Likes
Like

Posted 25 February 2013 - 02:19 PM

I wish this forum would've been around when I posted this!
 

  • Using Goto is perfectly fine

This just popped into my mind:

goto.png


[ 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 Michael Tanczos   Senior Staff   -  Reputation: 5451

Like
0Likes
Like

Posted 25 February 2013 - 02:27 PM

I wish this forum would've been around when I posted this!
 

 

  • Using Goto is perfectly fine

This just popped into my mind:

goto.png

 

Brilliant.  =)    I was trying to find a comic that embodied this idea.. yours is better.   



#5 slicer4ever   Crossbones+   -  Reputation: 3981

Like
1Likes
Like

Posted 25 February 2013 - 04:50 PM

   ....
   // tCount keeps showing up negative here for some reason..  it should never be negative
 
   tCount = sqrt(tCount*tCount);  // Fixed!
 

o god, i laughed far too hard at this one.


Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#6 FLeBlanc   Crossbones+   -  Reputation: 3117

Like
1Likes
Like

Posted 25 February 2013 - 04:55 PM

33 parameters? Yikes. Reminds me of something I did once when I was learning, a long long time ago. I wrote a function that took 25 parameters. It was for a tile engine, and the 25 parameters represented the values of each tile in a block of 5x5 tiles that were used to calculate some sort of classification code. Even worse, I named them all letters of the alphabet, so I had something like int calculateMegaTileCode(char a, char b, char c....). It was... man, it was horrible. I spent hours laboriously writing that function as a HUGE chunk of if (a==0 && b==0) statements. I was actually proud of it and myself when I finished it. I was 14, and I felt like I had just completed the most complicated and awesome piece of code anyone had ever written. Eight years later when I looked at it just for nostalgia's sake I nearly wept.



#7 slicer4ever   Crossbones+   -  Reputation: 3981

Like
1Likes
Like

Posted 25 February 2013 - 05:02 PM

33 parameters? Yikes. Reminds me of something I did once when I was learning, a long long time ago. I wrote a function that took 25 parameters. It was for a tile engine, and the 25 parameters represented the values of each tile in a block of 5x5 tiles that were used to calculate some sort of classification code. Even worse, I named them all letters of the alphabet, so I had something like int calculateMegaTileCode(char a, char b, char c....). It was... man, it was horrible. I spent hours laboriously writing that function as a HUGE chunk of if (a==0 && b==0) statements. I was actually proud of it and myself when I finished it. I was 14, and I felt like I had just completed the most complicated and awesome piece of code anyone had ever written. Eight years later when I looked at it just for nostalgia's sake I nearly wept.

when i was starting out in lua(and in programming in general), i wrote a risk clone(the board game), i hard-coded each country connection by using huge if/else if blocks, the pain of making a small change was....intense... worse yet, i repeated the huge if/else if block at several diffrent points in the program.

 

the game was never finished, and the file was a couple megs big(i didn't even break the game into seperate files cause i didn't know how).

 

it probably stands as the worse most complicated thing i've ever programmed. (and for some reason, i was really proud of what i was doing.)


Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#8 Mussi   Crossbones+   -  Reputation: 2098

Like
2Likes
Like

Posted 25 February 2013 - 06:37 PM

if(lolReturnThisInstead == true)
	return true;
else
	return false;


#9 Sik_the_hedgehog   Crossbones+   -  Reputation: 1833

Like
0Likes
Like

Posted 25 February 2013 - 09:37 PM

I wish this forum would've been around when I posted this!

I think that beats the record I saw in TDWTF...


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.

#10 BruceCichowlas   Members   -  Reputation: 106

Like
1Likes
Like

Posted 25 February 2013 - 10:23 PM

While helping with QA for Lotus Notes, I found my favorite all-time bug.  The symptom was that somehow application processing became gated by mouse interrupts.  So nothing would process at all unless you moved the mouse.  Better, the faster you moved the mouse the faster things got done!  Interrupt processing must have become entangled somehow, but it was really fun to demonstrate!



#11 NightCreature83   Crossbones+   -  Reputation: 3032

Like
0Likes
Like

Posted 26 February 2013 - 01:54 AM

One of the best comments I have found in a code base was "Ow magic numbers, guide us to the light!"


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#12 swiftcoder   Senior Moderators   -  Reputation: 10364

Like
0Likes
Like

Posted 26 February 2013 - 08:29 AM

I wish this forum would've been around when I posted this!

Your wish is my command.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#13 Sik_the_hedgehog   Crossbones+   -  Reputation: 1833

Like
5Likes
Like

Posted 26 February 2013 - 09:39 PM

That must be like the first time a thread is four years older than the forum it's in.


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.

#14 ManTis   Members   -  Reputation: 1006

Like
1Likes
Like

Posted 06 March 2013 - 01:13 AM

if (x^2>0) then patato else tomato

is it supid enough for this new forum ? ^^

Sorry =)

 

This is stupid because the answer is always potatoph34r.png

Of course you can replace patato with tomato. If you prefer tomato. Do you like patato ?

 

Wrong. Your code is obfuscated way of checking if (x != 0)

 

I can't find the screenshot any more, but in one of my past companies, we had cool functions like this one:

int GetID()
{
    return 4;
}

 

and this function would be overloaded for each and every object, with different (well, not always, as I noticed during debugging), typed by hand (sometimes commented // this ID is 4!) value.

 

Yay!


If only noobs were boobs... the world would be a better place.

#15 Olof Hedman   Crossbones+   -  Reputation: 2949

Like
0Likes
Like

Posted 06 March 2013 - 01:53 AM

post removed because of stupid contents ;)

should wake up before I post...


Edited by Olof Hedman, 06 March 2013 - 01:56 AM.


#16 Tournicoti   Prime Members   -  Reputation: 684

Like
0Likes
Like

Posted 06 March 2013 - 03:57 AM

@Mantistongue.png

Yes, not great wink.png, let me elaborate :

 

optimistic version :

if (x==0) then rolleyes.gif   else angry.png

 

pessimistic version :

if (x!=0) then angry.png  else rolleyes.gif

 

 

Now it should make perfectly sense blink.png  (cf ZE state of the art in term of conditional branch)

 

By the way, do you like boats ? (I'm about to create a poll on that)


Edited by Tournicoti, 06 March 2013 - 10:24 AM.


#17 Zipster   Crossbones+   -  Reputation: 876

Like
2Likes
Like

Posted 13 March 2013 - 04:01 PM

ineffective_sorts.png



#18 Oberon_Command   Crossbones+   -  Reputation: 1963

Like
2Likes
Like

Posted 14 March 2013 - 12:29 PM

Sleep sort!
#!/bin/bash
function f() {
    sleep "$1"
    echo "$1"
}
while [ -n "$1" ]
do
    f "$1" &
    shift
done
wait
example usage:
./sleepsort.bash 5 3 6 3 6 3 1 4 7
edit: removed link to source since it apparently has NSFW material that I didn't notice before posting.

Edited by Oberon_Command, 14 March 2013 - 12:33 PM.






PARTNERS