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?
Here's one... (Score:5, Funny)
One word.. (Score:5, Funny)
Ol' Slashy (Score:1, Funny)
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.
University Assignments. (Score:5, Funny)
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.
Re:Wow. Talk about old news. (Score:5, Funny)
The editor might have approved this submission just to meet some kind of deadline or a minimum requirement.
Re:Here's one... (Score:5, Funny)
Never (Score:4, Funny)
My boss however *only* does coding tricks. And he puts them in one big 1k line function.
And is proud of it.
Deadline is not the problem (Score:2, Funny)
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.
Sucker punch (Score:4, Funny)
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).
Re:University Assignments. (Score:1, Funny)
This tactic works on the job too. I congratulate you on foresight.
Re:Really? Not Slashdot's fault, if so... (Score:5, Funny)
Where'd he get to anyway?
Study Assignment (Score:5, Funny)
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.
Re:Wolf 360 hack (Score:3, Funny)
(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)
complex finance math (Score:3, Funny)
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.
Re:Really? Not Slashdot's fault, if so... (Score:3, Funny)
Re:Deadline is not the problem (Score:5, Funny)
Re:Wrong question (Score:5, Funny)
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)
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.
Re:Study Assignment (Score:2, Funny)
Re:Wow. Talk about old news. (Score:5, Funny)
> 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.
Re:University Assignments. (Score:4, Funny)
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..
Re:One word.. (Score:2, Funny)
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...
Yep, The Best! (Score:1, Funny)
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:
New London Underground station??? (Score:2, Funny)
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! :)
syntactic sugar (Score:2, Funny)
syntactic sugar is just fine, but what I would really like is syntactic caffeine.
Re:One word.. (Score:3, Funny)
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.
Re:complex finance math (Score:3, Funny)
> 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...
We in the Linux camp never do that sorta stuff... (Score:2, Funny)
I program small games (Score:4, Funny)
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!
Re:VB6: Lost source code - Ultimate repack (Score:5, Funny)
"Wow, assembler code."
"It must be highly optimized."
"Told you it was a good idea to buy it."
The Fucksort Incident (Score:5, Funny)
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.
Re:One word.. (Score:5, Funny)
Pyramid? It looks more like the players' ship sprite from Galaga, rotated 90 degrees...
Damn, now I want to play Galaga...
Re:One word.. (Score:5, Funny)
So formatting is worthless, then?
No, formatting is for successors and maintainers. As fellow coders, they're not human, strictly speaking.
Re:University Assignments. (Score:5, Funny)
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>
Re:Here's one... (Score:3, Funny)
Don't be absurd. Even the lowliest coder would know enough to write #DEFINE PSEUDO_RND_BSOD = 1
Re:One word.. (Score:2, Funny)
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.
Re:One word.. (Score:4, Funny)
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)
10 Print "No"
20 Goto 10
Re:Here's another one... (Score:4, Funny)
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]