Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Programming Entertainment Games IT Technology

Dirty Coding Tricks To Make a Deadline 683

Gamasutra is running an article with a collection of anecdotes from game developers who had to employ some quick and dirty fixes to get their products to ship on time. Here's a brief excerpt: "Back at [company X] — I think it was near the end of [the project] — we had an object in one of the levels that needed to be hidden. We didn't want to re-export the level and we did not use checksum names. So right smack in the middle of the engine code we had something like the following. The game shipped with this in: if( level == 10 && object == 56 ) {HideObject();} Maybe a year later, an artist using our engine came to us very frustrated about why an object in their level was not showing up after exporting to what resolved to level 10. I wonder why?" Have you ever needed to insert terrible code to make something work at the last minute?
This discussion has been archived. No new comments can be posted.

Dirty Coding Tricks To Make a Deadline

Comments Filter:
  • by Quartz25 ( 1195075 ) on Wednesday August 26, 2009 @02:43AM (#29197439) Homepage
    Right before I left from Microsoft: int security = *NULL; // eat it!
  • One word.. (Score:5, Funny)

    by consonant ( 896763 ) <shrikant.n@NOspAm.gmail.com> on Wednesday August 26, 2009 @02:47AM (#29197461) Homepage
    GOTO :-) (or is that two..?)
  • Ol' Slashy (Score:1, Funny)

    by Tablizer ( 95088 ) on Wednesday August 26, 2009 @02:50AM (#29197475) Journal

    Slashdot added a fudge th at mad e tex t h a ve ext ra sp ace s. Ho pe no bo dy foun d i t.

  • by Anonymous Coward on Wednesday August 26, 2009 @02:59AM (#29197539)

    Once I had an assignment due and at the last minute before being evaluated, realized I had made a huge mistake, even though the code looked OK...

    Too much time playing games in class and I was about to fail the course unit if I didn't pass that one test (right at the end of a semester)

    So I ran the program, adjusted the output in a word processor, saved it as a file and threw some code hidden in the comments that read the file, outputted it and exited.

    Three minutes later my code was evaluated... I was the only one who passed.

    Fortunately, no one investigated too carefully at the time why I was the only one who passed, because after trying to fix the code later in my own time, I realized the source data we were all supplied was corrupted.

    Inevitably, Later the same lecturer came to the same conclusion when his program didn't work either and cornered me to ask why mine worked (of course he was suspicious). Thinking quickly, I told him my source data was corrupted and that I fixed that first so my program would work. I don't know if he believed me, but he accepted the story.

    Fortunately, I got away with it and I got to keep the pass.

  • by melikamp ( 631205 ) on Wednesday August 26, 2009 @03:06AM (#29197595) Homepage Journal

    The editor might have approved this submission just to meet some kind of deadline or a minimum requirement.

  • by pinkushun ( 1467193 ) on Wednesday August 26, 2009 @03:08AM (#29197605) Journal
    Were you also responsible for #DEFINE RND_BSOD = 1 ?
  • Never (Score:4, Funny)

    by ChienAndalu ( 1293930 ) on Wednesday August 26, 2009 @03:09AM (#29197617)

    My boss however *only* does coding tricks. And he puts them in one big 1k line function.

    And is proud of it.

  • by nomad-9 ( 1423689 ) on Wednesday August 26, 2009 @03:12AM (#29197637)
    In the real world there are deadlines, and it's entirely the developer's responsibility to be able to meet those deadlines without using such "dirty coding tricks". Good developers should have tested their code so as to not have serious problems to fix at the last minute, and designed it so as to be able to extend it easily.

    And putting such "if" statements is not solving the problem - not even temporarily - but hiding the bug.

    Right, nobody said it was easy. That's probably why software development is not for everybody.
  • by Anonymous Coward on Wednesday August 26, 2009 @03:14AM (#29197645)

    When my deadline comes up and I haven't produced I wait for my boss to ask me for the code then I sucker punch him and run away. The trick is to hold down short term contracts and give false references and hire someone to back them up (another dirty trick). That also makes it easier to dodge the cops when your boss presses charges. It's getting harder though with all this talk of test driven development and short incremental releases. Then the trick becomes to write the most meaningless trivial unimportant tests first - but crucially tests that you can make pass quickly so you don't have to do any real work.

    (For anyone insane enough not to realise it, this is a joke. Don't try this at home...or at work).

  • by Anonymous Coward on Wednesday August 26, 2009 @03:18AM (#29197683)

    This tactic works on the job too. I congratulate you on foresight.

  • by fractoid ( 1076465 ) on Wednesday August 26, 2009 @03:54AM (#29197879) Homepage
    John Titor sent it just before disappearing.

    Where'd he get to anyway?
  • by LKM ( 227954 ) on Wednesday August 26, 2009 @03:55AM (#29197887)

    This was a pretty important assignment back when I was studying computer science. It added to the final mark mark for that particular class. The task was to write a reasonably complex application in Prolog or some functional programming language, I can't remember which it was. I think the goal was to pair males and females based on their preferences, and find the optimal solution. Of course, I screwed up royally, and nothing worked five minutes before I had to demonstrate my solution.

    So in the final five minutes, I changed my code so it would avoid the parts which put it into an infinite loop, and instead simply output a random result. My goal was to tell the prof that it had worked a few minutes earlier, and that I didn't know what had gone wrong, and could I please have another week?

    So I demonstrated my app, it gave its random output, and I was about to start with my "damn, it used to work properly" spiel when he said (and this is actually true, even though it sounds unbelievable):

    "That's great! The result is correct, and your app is also quite a bit quicker than my own implementation of the problem. Congratulations, I think you're the only one so far who managed to get the correct result so far."

    I was so taken aback that I probably just stared at him for a few seconds. Then, I stupidly said "So... You want to see my code?" but he was like "No, the result is correct, and your implementation is very fast, so I don't need to see the code. Good job. Send in the next guy."

    And so I did.

  • by andy_t_roo ( 912592 ) on Wednesday August 26, 2009 @03:56AM (#29197891)
    my favorite hack is doing object click detection by rendering objects in a function pointer (4 byte pointers, rgba colour buffer .... ) -- when you click, a render pass is done with no lighting, effects, ... , and with each object coloured according <rgbaColour>object->onClick. To act on a click, read of the colour of the pixel under the mouse, and call it :)

    (oh, and solaris lies about giving you rgba -- it only gives you rgb -- my code would work on one of the uni servers, but not on another)
  • by Anonymous Coward on Wednesday August 26, 2009 @04:04AM (#29197957)

    I worked with some finance guy who was convinced that the square root of a negative number -x was -sqrt(x), and wouldn't hear otherwise. I hacked sqrt(x) to return sgn(x)*sqrt(fabs(x)), but he complained that when he squared the answer, he didn't get back a negative number. Luckily our code was C99 so I changed his dollar type to be "double complex", made him use the complex sqrt, and changed his print function to display creal(x) - cimag(x). The guy said things worked great. I was glad to hear that, but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.

  • by fractoid ( 1076465 ) on Wednesday August 26, 2009 @04:05AM (#29197963) Homepage
    I knew it! It really WAS true!
  • by oldhack ( 1037484 ) on Wednesday August 26, 2009 @04:06AM (#29197973)
    Slashdot sorely needs "douchebag" moderation.
  • by Opportunist ( 166417 ) on Wednesday August 26, 2009 @04:10AM (#29198011)

    Probably. But reading a stream of "nope", "sorry", "you're kidding", "good one" ... answers leads to a lot of redundant mods but no good entertainment.

  • Who hasn't? (Score:5, Funny)

    by Opportunist ( 166417 ) on Wednesday August 26, 2009 @04:29AM (#29198139)

    After years of programming, I guess everyone had to cut some corners sometimes. It's also not (always) a problem of goofing off, a module you depend on not shipping in time but you being required to keep your deadline can already force you into doing just that: Delivering a hack that 'kinda-sorta' works, or at least the customer won't notice 'til we can ship the patch.

    Yes, that happens often. It's dubbed "Bananaware". Delivered green and ripens with the customer.

  • by mehrotra.akash ( 1539473 ) on Wednesday August 26, 2009 @04:41AM (#29198245)
    the opposite happened to me today, made a C++ program to demonstrate the use of classes and made full use of constructors, destructors,data hiding and DMA show it to the prof., he stares at it for 5 mins and then tells me to make everything in the class public and do the thing using arrays only....
  • by 7 digits ( 986730 ) on Wednesday August 26, 2009 @04:57AM (#29198341)

    > it's the comments that are worth reading

    More specifically the comments in the article. I loved this one:

    "Back on Wing Commander 1 we were getting an exception from our EMM386 memory manager when we exited the game. We'd clear the screen and a single line would print out, something like "EMM386 Memory manager error. Blah blah blah." We had to ship ASAP. So I hex edited the error in the memory manager itself to read "Thank you for playing Wing Commander.""

    That's awesome.

  • by consonant ( 896763 ) <shrikant.n@NOspAm.gmail.com> on Wednesday August 26, 2009 @04:59AM (#29198363) Homepage

    Similar story.

    In one of my "Intro to C" mid-term exam, one of the (sit down in the 'puter lab and spew code type) assignments was a simple string manipulation exercise. After I was done with the program, while sitting around waiting for the output-verifying lab drone to come over to my place, I noticed all she was doing for the other folks with the same assignment question was key in the same series of words as test inputs. I saw this, and quickly whipped up another little program that basically displayed a prompt, and did a printf("{hard-coded desired output for same set of words}"); and ran this piddly little pile of 'code' when she stopped by my machine.

    Sadly, I passed..

  • by Hattmannen ( 658936 ) on Wednesday August 26, 2009 @06:38AM (#29198907) Homepage

    Such loops are almost certainly buggy

    [citation needed]

    That seems a bit redundant. You just cited him, didn't you? I get the strangest feeling of recursion when someone quotes somebody else and asks for a citation...

  • by Anonymous Coward on Wednesday August 26, 2009 @06:46AM (#29198951)

    I had a project which was built on a really old CMS that was badly written, we had extended it and hacked it to bits so many times it just wasnt funny.

    We had an error somewhere in the code, but couldnt for the life of us figure out where, eventually I resorted to this:

  • by Anonymous Coward on Wednesday August 26, 2009 @06:51AM (#29198989)

    First year at university, as part of the end of year project, we coded a shortest path algorithm to work out the distance between two stations in the London Underground system. However at 4am a couple of hours before the class presentation we discovered a bug! This was that if you chose the station 'Bank' it could for example take you to 'Embankment' (since it contains 'bank'). Our 'fix'?? We renamed Embankment to... Embonkment! Nobody realised in the presentation! :)

  • by sigxcpu ( 456479 ) on Wednesday August 26, 2009 @07:20AM (#29199133)

    syntactic sugar is just fine, but what I would really like is syntactic caffeine.

  • by beelsebob ( 529313 ) on Wednesday August 26, 2009 @07:31AM (#29199177)

    I agree, if you need cleanup code... But I don't write code with side effects, so there's no problem whatsoever. No side effects means no clean up.

  • by Xenographic ( 557057 ) on Wednesday August 26, 2009 @07:33AM (#29199191) Journal

    > I was glad to hear that, but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.

    What? I'm sure most finance guys are adept enough at counting both real and imaginary dollars, so having complex dollars isn't really that complex...

  • by Becausegodhasmademe ( 861067 ) on Wednesday August 26, 2009 @08:16AM (#29199483)
    That's the good thing about open source! All of the dirty hacks the devs use eventually get weeded out of the code as time goes on! Honest!
  • by selven ( 1556643 ) on Wednesday August 26, 2009 @08:20AM (#29199521)
    I always just hard-code all my levels - it's easier to just go back and recompile (which takes 15 seconds in C or 0 seconds in python) than code all the extra logic in for reading from files. As another plus, this makes it harder for other people to cheat. Speaking of cheating, once I called my player save file "makefile" to discourage people from looking at it or modifying it.

    And, I never split my code into multiple files - scroll and Ctrl+F were good enough for my grandfather, and they're good enough for me!
  • by mrwolf007 ( 1116997 ) on Wednesday August 26, 2009 @08:43AM (#29199761)
    Yeah, just think what those guys thought when they saw the code.
    "Wow, assembler code."
    "It must be highly optimized."
    "Told you it was a good idea to buy it."
  • by ari_j ( 90255 ) on Wednesday August 26, 2009 @08:51AM (#29199897)
    Back in college, we were at a programming competition and I was the on-the-keyboard coder for one of the problems. We had 10 minutes for the problem and I coded it quickly, having decided on the best algorithm before sitting down. Part of the solution was a sorting routine on a list. We were using Visual C++ although we were all not C++ experts at the time, and so rather than mess with the STL and the possibility of having to read documentation, I did it all from scratch. I knew that sort was already in use by the standard library, so I called my routine mysort.

    Apparently, however, Visual C++ includes a mysort in its standard library. So, with the clock ticking down and the solution's only impediment to our victory being an identifier conflict, I renamed the routine the way that any one of us would have: myfuckingsort. We won the competition.

    In this particular competition, the judges were not supposed to read our code - they just run the output of your code on the input and check for correct output - so I felt safe when I typed what I did. However, one of them came up to us afterwards and told us that they do in fact usually read the code of the winning team to see if we did anything unique in our solution. Yep. Sure did. And my classmates and professors never did let me live down what was affectionately nicknamed the fucksort algorithm.
  • by geminidomino ( 614729 ) * on Wednesday August 26, 2009 @08:58AM (#29199987) Journal

    Pyramid? It looks more like the players' ship sprite from Galaga, rotated 90 degrees...

    Damn, now I want to play Galaga...

  • by geminidomino ( 614729 ) * on Wednesday August 26, 2009 @09:03AM (#29200079) Journal

    So formatting is worthless, then?

    No, formatting is for successors and maintainers. As fellow coders, they're not human, strictly speaking.

  • by geminidomino ( 614729 ) * on Wednesday August 26, 2009 @09:21AM (#29200345) Journal

    To this day I continue to find typos in my code but less and less bugs-in-libraries.

    That's because the ratio of code-bugs to library-bugs increases with the programmer's age, even if both the code and the library remain unchanged. </zen>

  • Don't be absurd. Even the lowliest coder would know enough to write #DEFINE PSEUDO_RND_BSOD = 1

  • by dna_(c)(tm)(r) ( 618003 ) on Wednesday August 26, 2009 @10:13AM (#29201189)

    Why are their numbers before the lines, and what is a GOTO?

    once upon a time their weren't any GUIs on personal computers.

    Don't GOTHERE.

  • by MikeBabcock ( 65886 ) <mtb-slashdot@mikebabcock.ca> on Wednesday August 26, 2009 @10:23AM (#29201363) Homepage Journal

    If you were going to do that without goto, use a while with a break instead of ugly nested ifs.


    while(1)
    {
            if (!start_condition) break;
            action1();
            cleanup1();
            if (!test_condition1) break;
            action2();
            cleanup2();
            if (!test_condition2) break;
    }

    And so on ... it basically gets you exception handling formatted code. Of course, goto is probably still cleaner :)

  • Re:Sorry... (Score:2, Funny)

    by gt6062b ( 1548011 ) on Wednesday August 26, 2009 @10:43AM (#29201689)

    10 Print "No"
    20 Goto 10

    Please hand over your geekbadge...

    10 Print "No"
    20 Goto 10

  • by Chapter80 ( 926879 ) on Wednesday August 26, 2009 @12:17PM (#29203415)

    This is the code for the Apollo 11 lunar lander flight computer.

    HELP!

    I'm trying to get this code to work. I'm at an altitude of 6,000 ft, hovering over the Sea of Tranquility, and the darn thing keeps crashing! (The code, not the lunar module.)

    PLEASE don't connect me to that Bangalor helpdesk again! I am in serious trouble here!

    Has this been tested for Y2K compliance?
    Did we not pay our last support bill?

    - Major Tom [wikipedia.org]

Those who can, do; those who can't, write. Those who can't write work for the Bell Labs Record.

Working...