Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Share your dumb programmer stories!

Name: Anonymous 2013-02-18 23:08

And stuff similar to this subject. I like to hear dumb people stories.

Look at other people's code, see this.

public static int makePositive(int num) {
    if(num < 0) {
        int pos = num-num-num;
        return pos;
    } else {
        return num;
    }
}

Name: Anonymous 2013-02-18 23:11

Name: Anonymous 2013-02-18 23:17

That cannot be real.

Name: Anonymous 2013-02-18 23:28

>>3

It works, but it's a stupid way of doing it.

Name: Anonymous 2013-02-18 23:30

i'd name the variable 'nom'
>int pos = nom-nom-nom;
:3

Name: Anonymous 2013-02-18 23:34

>>5

lol

Name: Anonymous 2013-02-19 0:16


int abs(int num)
return num * (num>0 * 2 - 1);

Name: Anonymous 2013-02-19 21:28

int add(int x, int y) // only works for positive numbers
   if(y == 0) return x
   return add(x + 1, y - 1)

Name: Anonymous 2013-02-19 21:36

>>8
You have read your SICP.

>>2
I fucking love you, Nikita.

Name: Anonymous 2013-02-19 22:24

int add(int x, int y) // ftfy!
   if(y == 0) return x
   if(y < 0) return add(x - 1, y + 1)
   return add(x + 1, y - 1)

Name: Anonymous 2013-02-19 23:07

function add(x, y) {
   if(y == 1) { return x + 1; }
   var z = x % y;
   if(z == 0) { z = 1; }
   return add(x + z, y - z);
}

Works for positive numbers, at least.

Name: Anonymous 2013-02-19 23:18

data Num = Z | S Num deriving (Show, Eq)
add (S x) y = add x (S y)
add Z y = y

Name: Anonymous 2013-02-19 23:38


void SwapValue(int a, int a2){//INTEGERS'VE TO B DIFFERENT TO //WORK, ANYWAYS IF THEY'RE NOT U DON'T NEED THIS
int *aux=&a;

int *aux2=&a2;

int *aux3=aux;

aux2=aux;

aux=aux3;

std::count<<"SWAPED VALUES"+a"\n"+"AND"+b;

if(a==a2||a2==a){
std::cout<<"ERROR\n!\n!\n! error code 20!!!!!!!\n"
throw 20;

}

}

Name: Anonymous 2013-02-19 23:52

Do not convey you shitty code with shittier code.
Read good books and start programming instead of shitposting.

Name: Anonymous 2013-02-20 4:54

answers.yahoo.com

Name: Anonymous 2013-02-20 5:09

Name: Anonymous 2013-02-20 7:49

>>7
int abs(int x){
    int y = x >> 31;
    return (x+y)^y;
}

Name: Anonymous 2013-02-20 8:11

Name: Anonymous 2013-02-20 8:13

>>18
Go play in traffic.

Name: Anonymous 2013-02-20 8:40

Name: Anonymous 2013-02-20 21:40

(Commercial programmer here, working for large IT company)

Worst I've seen was some Java code in a printing-related class which defined two separate "rounding" functions. Each function used a bunch of ifs, type casts, and String formatting methods. They turned out to be exactly equivalent to (int) Math.floor(x) and (int) Math.ceil(x). But probably 50 times slower.

Second worst, an intern once added a new field to one of the main UI components of our application. It was a boolean field called simply theBool. Had something to do with animation and went through some fairly complex state changes, but I never managed to figure out exactly what it did. theBool. Thankfully the project died soon after.

Name: Anonymous 2013-02-20 22:07

>>21
Hungarian notation was invented by the Communists to hold back the progress of computing in the Free World.

Name: Anonymous 2013-02-20 22:25

>>21
Those who do not learn from history are doomed to reimplement it poorly.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List