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

Pages: 1-

Code from others

Name: Anonymous 2010-10-01 12:09

We all read a lot of code. Post some lines that lets you always facepalm. Example:


bool some_funtion(...)
{
    ...
    ...

    if ( other_func() && something_else )
        return true;
    else
        return false;
}

Name: Anonymous 2010-10-01 12:22

We all read a lot of code. Post some lines that lets you always facepalm.

Name: Anonymous 2010-10-01 12:38

I'm too lazy to post it here... but i've seen stored procedures that returns HTML with tables and all that shit :S

Name: Anonymous 2010-10-01 12:39

Name: Anonymous 2010-10-01 13:07

No examples to hand, but mainly it's when people have duplicated some code that should have really been refactored to have a common function that handles both scenarios.  It just seems so obvious. I believe that code should as small and simple as possible, not for optimization, but the simpler it is, the nicer it is to maintain

Name: Anonymous 2010-10-01 16:10

We all read a lot of code

Name: Anonymous 2010-10-01 17:25

system("pause");

int someFunc()
{
  ...
  return someFunc();
}


sleep(1); //don't take away all the CPU resources

Name: Anonymous 2010-10-01 17:50

Using a variable flag to break out of a deeply nested for or while loop instead of just using goto.

Name: Anonymous 2010-10-01 18:16

>>8
BLASPHEMER

Name: Anonymous 2010-10-01 19:05

>>5
I was in a situation like this a night or two ago.  Assuming two arrays, both of size n, and consistent modification between the two, I had to decide whether I wanted to iterate for each array individually (same algorithm, put into a separate function) or combining access to both arrays in the the same loop.  I wasn't sure if there was even a difference.

Name: Anonymous 2010-10-01 19:27

>>10
Well if teh resulting refactored common function is a only a few lines, then yeah it's not necessarily worth it...but I'm talking 30 line blocks of code just copy and pasted.

Name: Anonymous 2010-10-01 20:47

For some reason I can't see what's wrong with >>1

Name: Anonymous 2010-10-01 21:08

Name: Anonymous 2010-10-01 22:02

>>1
This is OK code - you can put breakspace on either of returns. Though I'd remove else clause and saved 1 line and 4 spaces

Name: Anonymous 2010-10-01 22:04


int codeReuseMyAnus()
{
    //const int VALUE_1 = 1;
    const int VALUE_1 = 4;
    foo(VALUE_1);
    bar(VALUE_1);
    etc
}

Name: Anonymous 2010-10-01 23:36

*cracks knuckles*


if (someBool == true) { ... }


j++;
if (j < someVal) { ... }


void someFunc() {
  ...
  if (someBool) {
    return;
  }
}


Also,
>>14
No, no it isn't.  If you need to use breakpoints, modify the code to allow it, and then REVERT IT TO GOOD CODE when you're done.  Or get a real IDE that let's you put breakpoints wherever.

Name: Anonymous 2010-10-02 6:50

>>12,14
Novice coders detected

Name: Anonymous 2010-10-02 7:55

if(obj.equals(null) == false){
  // do stuff with obj
}

Name: Anonymous 2010-10-03 3:13


for (;;) { ... }

if (x < y) {
  ...
} else if (x >= y) {
  ...
}

#define SOME_CONSTANT 1

Name: Anonymous 2011-01-31 20:25

<-- check em dubz

Name: Anonymous 2013-09-01 10:22


All things are possible through Allah my friend.

May take a little while though.

Name: Anonymous 2013-09-01 11:08


Japanese customs allows me 3 bottles of booze.

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