Hi all,

This is completely off-topic, but I wanted to share a few "programmer private 
jokes", that is to say fun things I found in code written by unexperienced 
programmers (not things found on the web, just what I saw)...
Note: There is no specific order (= the first/last is not necessarily the 
funiest).

1. No breaks and useless 'if':
if (param==CONSTANT1 || param==CONSTANT2 || param==CONSTANT3 ...) {
    switch(param) {
        case CONSTANT1:
            value=1;
        case CONSTANT2:
            value=2;
        case CONSTANT3:
            value=3;
        // ... and no 'default' of course.
    }
}


2. "NOP in da house"
Here, "NOP" is a macro that does nothing useful, generally used to put 
breakpoints. But when you have a pile of them, that looks fun:
switch(value) {
    case 'a': NOP; break;
    case 'b': NOP; break;
    case 'c': NOP; break;
    case 'd': NOP; break;
    // ...
    case -1: NOP; break;
    default:
        NOP; break;
}


3. "NOP is good for you"
Here, the code *IS* intended to do something (that's not supposed to be a 
"NOP"):
if (value == 32) {
    value = 32;
}


4. What possibly does this thing?
    value = value++;
Actually, it seem to be compiler and type dependant... for integers, some 
compilers leave the variable unchanged, some increment it.

Cheers! :)

Sukender
PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to