77
pajaja
7y

I have a lot of interesting code snippets from some kind of inhouse CRM/billing software, but for now let's look at this very useful PHP function.

Comments
  • 13
    Oh man this is bad- not even any commenting to help future developers.
  • 7
    At least if you find print offers a big performance difference, you only have to update it in one place 😉
  • 2
    Yeah, comment would be nice.
    But sometimes you need strange stuff, if you cannot figure out or the eliminate the root cause.

    I once had to create two functions in a proprietary scripting language, just because the implicit conversion string<->int didn't work in all places and this was the workaround to force it:

    int toInt( int value ) { return value; }
    string toString( string str ) { return str; }

    Looks stupid, but worked.

    Or another example that was based upon spontaneous errors in the communication to an NXP chip after updating the GNU toolchain:

    void wasteTime( int nops ) {
    for(int i=0; i<nops; i++ ) {
    asm( "NOP" );
    }
    }

    I still don't know why this helped, and what difference the toolchain made. The old toolchain didn't need that and I even tried to diff the assembler output of the two toolchains, without success. Also looks stupid, but after some hours of pointless debugging, that stupid piece of code helped.

    At least I left comments to explain my foolishness.
  • 0
    @ddephor Trust me, when you see the rest of the code it becomes obvious that this is just an 'accident' :D
Add Comment