Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Dirty Coding Tricks To Make a Deadline

Soulskill posted more than 5 years ago | from the it-ain't-pretty-but-it-ain't-crashing dept.

Programming 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?

cancel ×

683 comments

Sorry! There are no comments related to the filter you selected.

Here's one... (5, Funny)

Quartz25 (1195075) | more than 5 years ago | (#29197439)

Right before I left from Microsoft: int security = *NULL; // eat it!

Re:Here's one... (2, Interesting)

Niris (1443675) | more than 5 years ago | (#29197459)

Oh how I wish I had modpoints. That gave me a good laugh before bed :D +1 point for you, good sir.

Re:Here's one... (5, Funny)

pinkushun (1467193) | more than 5 years ago | (#29197605)

Were you also responsible for #DEFINE RND_BSOD = 1 ?

Re:Here's one... (0)

Anonymous Coward | more than 5 years ago | (#29198021)

We had a nifty Shockwave 3D engine from yonks ago that we dug out for a project. Between flash-based interactive sections were 3D world activities. By the end of the project there were so many activities it came to about 100Mb zipped, and such a poor engine that memory leaks were abundant and while it ran fine for about 4 activities, by the end it crawled like a legless blind drunk puppy.
So two weekds before deadline, the 3D sections were replaced with pre-rendedered animations and I had to write a sequential loader in flash and hope the client didn't notice.
Got the file size down to 30Mb, and leaks/crashes were non-existant.
Why were we working in Flash/Shockwave? The client wanted it to run embedded in a website.

One word.. (5, Funny)

consonant (896763) | more than 5 years ago | (#29197461)

GOTO :-) (or is that two..?)

Re:One word.. (5, Informative)

wilx (1065624) | more than 5 years ago | (#29197633)

The goto statement is very useful. Your dislike of it is irrational. Do you even know why you do not like it? Often, goto is the best solution to given problem.

Re:One word.. (1)

blackraven14250 (902843) | more than 5 years ago | (#29197675)

So, where's your example?

Re:One word.. (2, Insightful)

EvanED (569694) | more than 5 years ago | (#29197691)

Error handling in C code is my typical example of that. It mostly avoids the need for lots of if statements to make sure that you clean up all that you need to and nothing more.

There are other ways to go about it, but in general I'm not convinced they are better.

Re:One word.. (3, Informative)

Anonymous Coward | more than 5 years ago | (#29197713)

So, where's your example?

Finite State Machines. They really are quite difficult to implement without goto logic and is exactly what you do when discussing theory.

Re:One word.. (0)

Anonymous Coward | more than 5 years ago | (#29197747)

My bad, I forgot about giant switches etc via state encodings. But as below says, they make error handling an easier task as well as some oddly structured loops for which try/catch logic doesn't get you all the way

Re:One word.. (1)

beelsebob (529313) | more than 5 years ago | (#29198177)

Huh?

FSMs are *easy* to implement without any goto. You simply use an array representing the out edges in the graph, and store the state you're in, then all you need is a loop checking which transition to take, and taking it.

Re:One word.. (2, Insightful)

fractoid (1076465) | more than 5 years ago | (#29197849)

Every control structure in C++ is equivalent to either a goto or jnz plus some syntactic sugar.

Re:One word.. (5, Insightful)

Derleth (197102) | more than 5 years ago | (#29198035)

I’m a goto-user, but this is a bad reason to use them: If you regard language features as ‘just’ syntactic sugar, why aren’t you programming in raw machine code? That is what everything eventually gets turned into anyway.

You use gotos when the normal control structures are inadequate somehow. It doesn’t matter what the compiler does; source code is for humans.

Example (5, Interesting)

Anonymous Coward | more than 5 years ago | (#29197927)

Example?  Right here:
#include <stdio.h>

void    *f(void)
{
a:
    printf("Here!\n");
    return &&a;
}

int     main(int ac, char **av)
{
    goto *f();
    printf("There\n");
    return 0;
}

Re:Example (1)

EvanED (569694) | more than 5 years ago | (#29198099)

What exactly is that a good solution to?

Re:Example (0)

Anonymous Coward | more than 5 years ago | (#29198279)

Obfuscation (at best). This is very unsafe code. It does a non-local goto from one function into another, and as that function exits it deallocates the other function's stack frame (or at least tries to), and returns to... who knows! But I found it curious one can even write such a thing.

Re:One word.. (5, Insightful)

Derleth (197102) | more than 5 years ago | (#29197983)

Breaking out of a deeply-nested loop, as can happen when you’re looking for a specific element in a multidimensional array. The alternative involves adding state variables and complicating the logic terribly.

Re:One word.. (0)

Anonymous Coward | more than 5 years ago | (#29198143)

Breaking out of a deeply-nested loop, as can happen when you’re looking for a specific element in a multidimensional array. The alternative involves adding state variables and complicating the logic terribly.

This hit the nail on the head.

Re:One word.. (1)

beelsebob (529313) | more than 5 years ago | (#29198201)

I use return for that. If I have deeply nested arrays, it's because I'm really representing some more complex data structure, so write a lookup function for that data structure, which itterates through to find the element, and returns, not gotos when it finds it. It's close to the same, but the control flow is much more easily recognised.

Re:One word.. (3, Insightful)

zwei2stein (782480) | more than 5 years ago | (#29198209)

Ewww.

1) decent languages support labeled for/while cycles and apropriate "break label" constructs. It is not so different from using goto but has much better semantic meaning and thus allows neat optimalizations (with, say, paralelization in mind)

2) if you do this kind of thing, you are MUCH better off separating lookup code to method or function and simply using return statement once you find it without having to break from cycles per se. Cleaner, more structured.

Re:One word.. (1)

msclrhd (1211086) | more than 5 years ago | (#29198253)

Or split out the element retrieval into a function that returns either a reference, pointer or iterator to the element, depending on how you are implementing the multi-dimensional array. You still need to check if an element was found, though (so pointer or iterator is better than a reference, otherwise you are looking at using something like a std::pair or tuple and then the interface gets messy again; exceptions are also a possibility, but are too heavyweight for this, especially in high-level physics or 3d geometry where performance is critical).

Re:One word.. (1, Insightful)

Anonymous Coward | more than 5 years ago | (#29197677)

It's not irrational. Very often goto is solution to a problem you shouldn't have.

That, of course, does not invalidate your last comment...

Re:One word.. (1)

Toonol (1057698) | more than 5 years ago | (#29197913)

I wouldn't say often, but occasionally, and it's a valuable tool. Goto and If are the primitives that all other control structures are derived from, and it's always useful to have those sorts of raw basics at your disposal. Rigidly adhering to a 'no Goto' policy is too dogmatic.

That said, I hardly ever need to use Goto. I'm prepared when the time comes, though!

Re:One word.. (2, Insightful)

Darinbob (1142669) | more than 5 years ago | (#29198103)

I think a lot of programmers are superstitious. They do what they teachers taught, without ever stopping and thinking about why they were taught that. So you see people instinctively avoid goto's, or forbid them outright when they get edit permission on style guidelines. I've seen some horrible stuff that avoids gotos, complicating code and making it difficult to read. They heard "goto considered harmful" and "you should prefer structured programming" and translated that internally into "thou shalt not use a goto". Some people even avoid "break" or "continue" in C because of similarity to a goto.

Similarly, the "there shall be only one exit from a function" is often used as a tautology by some. Combine that with a prohibition on gotos (that lets you jump to the cleanup) and things get ugly.

Granted, you can get rid of a lot of gotos with some simple language additions (such as a "finally" clause or automatic destructors), but if these don't exist the goto works just fine.

Re:One word.. (1)

zwei2stein (782480) | more than 5 years ago | (#29198265)

GOTO is weapon of mass code destruction in hands of novice programmer, I'd say that is good enough reason to be vary of its use.

Alternate structures that 'hide' goto exist for reason: They increase readability of code and add semantics to what is happening. Not to just get rid of eeeevil goto, but get rid of assemblerey 'jump'.

And frankly, I have yet to see goto use that was not caused by ignorance about some constructs - i.e. break.

Re:One word.. (0)

Anonymous Coward | more than 5 years ago | (#29198203)

call/CC is better!

return, break, continue? (3, Informative)

krischik (781389) | more than 5 years ago | (#29197771)

Have you ever wrote a function / procedure with more then one return statement? Or used break or continue in a loop? Then you can use goto as well. From a structure point of view goto, break, continue and return are all unconditional jumps. They are one of a kind. And looking back in retrospect: Since goto need to be paired with a label it's the least evil of the group.

Note that Pascal the archetype of structured programming had goto but it did not have break, continue or return.

Re:return, break, continue? (1)

pjt33 (739471) | more than 5 years ago | (#29197939)

Since goto need to be paired with a label it's the least evil of the group.

I don't follow that argument. Why wouldn't return, which doesn't need a label because it's always unambiguous, not be less evil?

Re:return, break, continue? (1)

beelsebob (529313) | more than 5 years ago | (#29198225)

The reason I consider goto evil is because it obfuscates control flow for the reader. They must search for the label to find out where control is going to. Return, break and continue do not have this effect.

Ol' Slashy (1, Funny)

Tablizer (95088) | more than 5 years ago | (#29197475)

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.

pretty much everytime I write in (2, Insightful)

buswolley (591500) | more than 5 years ago | (#29197479)

VBA

Balancing act (4, Interesting)

Tubal-Cain (1289912) | more than 5 years ago | (#29197489)

If you have short deadlines, you end up with issues similar to the bugs Ubuntu needs to smooth out every release. If you go with "It'll be finished when it is finished", Your stable releases can become ridiculously out of date between versions. Debian did a good thing by abandoning the open-ended release cycle in favor of the extremely long but predictable two-year deadlines.

Re:Balancing act (1)

moon3 (1530265) | more than 5 years ago | (#29197877)

predictable two-year deadlines

only in the world of open source..

Similar (2, Interesting)

kondziu (1543467) | more than 5 years ago | (#29197495)

In my last job I had to fix a project management application, because, to allow user administrative privileges, it checked the condition: if (user_id == 1 || user_id == 18 || user_id == 23) {...}. It had a whole system for managing privileges, but someone got lazy at this particular point.

Wow. Talk about old news. (1, Informative)

Jack9 (11421) | more than 5 years ago | (#29197517)

This is literally a dupe from 2000. Wow. It'll take me a bit to look it up...

Really? Not Slashdot's fault, if so... (2, Insightful)

Anonymous Coward | more than 5 years ago | (#29197561)

The Gamasutra article is dated August 20, 2009. I doubt any Slashdot contributor submitted a link to a 2009 story back in 2000.

Re:Really? Not Slashdot's fault, if so... (4, Funny)

fractoid (1076465) | more than 5 years ago | (#29197879)

John Titor sent it just before disappearing.

Where'd he get to anyway?

Re:Really? Not Slashdot's fault, if so... (4, Informative)

Trahloc (842734) | more than 5 years ago | (#29197919)

He's fighting in the civil war we're apparently not having, guess he fixed our timeline.

Re:Really? Not Slashdot's fault, if so... (2, Funny)

fractoid (1076465) | more than 5 years ago | (#29197963)

I knew it! It really WAS true!

Re:Really? Not Slashdot's fault, if so... (2, Interesting)

smash (1351) | more than 5 years ago | (#29198089)

Not having - yet.

Re:Wow. Talk about old news. (5, Funny)

melikamp (631205) | more than 5 years ago | (#29197595)

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

No it isn't. (0)

Anonymous Coward | more than 5 years ago | (#29197625)

Projects referred to include Doom 3 and the new Wolfenstein, which were not released in 2000. If it's a dup from 9 years ago, it was written by psychics.

Re:No it isn't. (0)

Anonymous Coward | more than 5 years ago | (#29197725)

Not necessarily:

http://www.xkcd.com/628/

Re:Wow. Talk about old news. (5, Insightful)

shish (588640) | more than 5 years ago | (#29197627)

This is one of those stories where the story isn't the point, it's the comments that are worth reading, so it's only a problem if we have the same comments :-P

Re:Wow. Talk about old news. (2, Interesting)

pjt33 (739471) | more than 5 years ago | (#29197899)

Quick, find the dupe and copy-paste all the +5 Insightfuls!

Re:Wow. Talk about old news. (5, Funny)

7 digits (986730) | more than 5 years ago | (#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.

Sorry... (0)

Anonymous Coward | more than 5 years ago | (#29197535)

10 Print "No"
20 Goto 10

University Assignments. (5, Funny)

Anonymous Coward | more than 5 years ago | (#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.

Re:University Assignments. (1, Funny)

Anonymous Coward | more than 5 years ago | (#29197683)

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

Re:University Assignments. (2, Interesting)

LaskoVortex (1153471) | more than 5 years ago | (#29197781)

We discovered that trick in O-chem lab too. You start with the percent yield to get an A on the lab and then back calculate your intermediate yields and amount of product you expected from the reagents you weighed. Fond memories.

Re:University Assignments. (1)

ShakaUVM (157947) | more than 5 years ago | (#29197811)

We discovered that trick in O-chem lab too. You start with the percent yield to get an A on the lab and then back calculate your intermediate yields and amount of product you expected from the reagents you weighed. Fond memories.

Yeah, I breezed through chemistry with that. =)

Once I dumped my entire experiment on the ground (and the teacher saw it) so I made sure my numbers weren't TOO accurate when I finished the lab.

Re:University Assignments. (2, Interesting)

mrsurb (1484303) | more than 5 years ago | (#29197869)

What I learnt in Physics: First draw your lines-of-best-fit, THEN plot your points.

Re:University Assignments. (2, Interesting)

Kentari (1265084) | more than 5 years ago | (#29198041)

This works well, until the teacher supplies clocks that have been tampered with to induce a 10% systematic error. You get to guess how many correct values of g turned up in that experiment... And who passed it.

Re:University Assignments. (1)

mehrotra.akash (1539473) | more than 5 years ago | (#29198285)

best solution take 1-2 readings VERY carefully and then use Excel goalseek to complete the rest have used C++ to solve many of my Maths P&C questions as well what would take me 10-15 mins atleast to solve and be done using a short 20-30 line prog in TC++(i think its even easier in python , dont know how 2 use it but)..

Re:University Assignments. (0)

Anonymous Coward | more than 5 years ago | (#29198291)

You thief! I have a patent on that NOVEL technique!

Re:University Assignments. (1)

rew (6140) | more than 5 years ago | (#29197813)

Oh yeah. Similar here. In an assignment where we were supposed to learn the advantages of pointers, I had to swap two records in a list. So the idea is that you just swap the pointers, and keep the (large) records in the same spot in memory, to prevent having to move the (large) memory area holding all the data in the record.

When I wanted to finish the assignment it didn't work as expected. After some frustration I ended up just swapping the whole records and then swapping the pointers back. The assignment got OK-ed.

I had already learned to use pointers the proper way. I just had to pass the class goal achieved!

Re:University Assignments. (1)

istartedi (132515) | more than 5 years ago | (#29197845)

Let me guess. You parlayed that talent into a fortune for a while at the first company you worked for after graduating: Enron.

Re:University Assignments. (1)

Sique (173459) | more than 5 years ago | (#29198087)

So basicly it's the StarTrek solution (as we all saw in "Wrath of Khan"): Modify the game if you can't beat it with the current rules.

Anonymous Coward (0)

Anonymous Coward | more than 5 years ago | (#29197553)

Holy Crap -- among those who've been in the industry for more than a couple of years, who hasn't?

Wolf 360 hack (3, Interesting)

anss123 (985305) | more than 5 years ago | (#29197599)

The deadline is looming, I can't spend much more time on this. So, I did the unthinkable -- I packed the controller id into the pointer parameter. I marked it as a horrible hack in a 4-line all-caps comment, and checked it in.

Does not sound so horrible, just make sure the 1,2,3,4 pointers never point at anything "free()"able and it'll work fine.

BTW, is that Wolf 360 game out?

Re:Wolf 360 hack (2, Funny)

andy_t_roo (912592) | more than 5 years ago | (#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)

Re:Wolf 360 hack (1)

fractoid (1076465) | more than 5 years ago | (#29198047)

I've done this with object IDs but... function pointers? That's deliciously evil!

Wrong question (5, Insightful)

julesh (229690) | more than 5 years ago | (#29197601)

Have you ever needed to insert terrible code to make something work at the last minute?

Wouldn't "have you ever shipped a product without needing to insert terrible code to make something work at the last minute?" be a more sensible question?

Re:Wrong question (4, Funny)

Opportunist (166417) | more than 5 years ago | (#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.

Never (3, Funny)

ChienAndalu (1293930) | more than 5 years ago | (#29197617)

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

And is proud of it.

Re:Never (1)

tsergiu (1576293) | more than 5 years ago | (#29198347)

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

And is proud of it.

He's got a big bag o' tricks.

Deadline is not the problem (2, Funny)

nomad-9 (1423689) | more than 5 years ago | (#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.

Re:Deadline is not the problem (5, Insightful)

93 Escort Wagon (326346) | more than 5 years ago | (#29197853)

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.

Yes, because deadlines are always reasonable and never pushed up. And change orders are a myth.

Re:Deadline is not the problem (5, Funny)

oldhack (1037484) | more than 5 years ago | (#29197973)

Slashdot sorely needs "douchebag" moderation.

Re:Deadline is not the problem (1)

dintech (998802) | more than 5 years ago | (#29198275)

He obviously works by himself in a rosy world where requirements and scope never change and nothing unexpected ever happens.

In fact, I bet he's coding on a UNIVAC I [wikipedia.org] in Pleasantville [wikipedia.org] . That must be nice.

Re:Deadline is not the problem (1)

glwtta (532858) | more than 5 years ago | (#29198133)

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.

Right, even if the "real world" did work that way, there are still plenty of unreasonable deadlines to contend with.

(though now that I think about it, the above was probably sarcasm; in which case: never mind)

Re:Deadline is not the problem (0)

Anonymous Coward | more than 5 years ago | (#29198165)

"the real world" ahha, there's the misunderstanding.

Re:Deadline is not the problem (1)

91degrees (207121) | more than 5 years ago | (#29198361)

The developers had the task of producing the game to spec on time. The spec included not having this particular object. The game was released to spec and on time.

Yes, they should have fixed this sooner. Since they didn't that isn't really a lot of help.

Sucker punch (4, Funny)

Anonymous Coward | more than 5 years ago | (#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).

Game Art (4, Interesting)

j-stroy (640921) | more than 5 years ago | (#29197759)

A 3d model export would break regularly screwing up the texture map orientation on certain polygons. The godawful export couldn't be fixed on the deadline, and risk management said best not to touch it cuz EVERYTHING might bust, let alone all the coders being nailed to the wall by the ship date. So I fixed the model files in an ascii editor. All the art builds that had tweaks needed this "touch" Since it was a hockey game, you can imagine how many goalie pads that was. Oh yeah, you couldn't see if the fixes were correct except in the game engine after more pipeline.

Technically not a code fix, but still a valid solution.

seen some bad shit. (5, Interesting)

Ziest (143204) | more than 5 years ago | (#29197765)

I once worked at a Fortune 25 company in Chicago. They had this ENORMOUS mainframe program written in COBOL that ran their order inventory system which accounted for 20% of the companies revenue. All the guys who wrote this grunting pig of a system had either retired or had passed away. In the middle of the code was the following;

    *
    * We don't know what this does.
    * Please leave it alone !
    *
        SET INSIDE-INDEX TO 1.
    *
    * We don't know what this does.
    * Please leave it alone !
    *

If this statement was commented out or removed the system stopped working. No one could find the problem. People had spent years looking for it but the code was such a mess and the documentation was so useless that they just left it alone and made a note that when the order inventory was re-done to make sure they left this "feature" out. I have been told that many old system have similar problems.
 

Re:seen some bad shit. (1)

setagllib (753300) | more than 5 years ago | (#29197875)

Even the most primitive data flow analysis would help track that down, but if the code isn't written with assertions all over, you never really know if it's consistent with assumptions or only fooling you all along. I don't write anything without assertions these days.

Re:seen some bad shit. (0)

Anonymous Coward | more than 5 years ago | (#29198037)

I don't write anything without assertions these days.

Sort of like

int assert_count = 0;

void assert( ... )
{
        assert_count++;
        _assert( ... )
} ...

int main
{
        printf( "hello world\n" );
        assert( assert_count > 0 );
}

Re:seen some bad shit. (1)

KonoWatakushi (910213) | more than 5 years ago | (#29198063)

Assuming that the compiler is working properly, probably so. However, it wouldn't be the first time that I have seen code which when removed breaks things horribly, even though it shouldn't. (It is also not rare to see code break at higher optimization levels...)

Agreed about the assertions. Does cobol even have those though?

Re:seen some bad shit. (1)

Heart Driven (1484993) | more than 5 years ago | (#29197907)

I once worked for a Belgian reseller company using PROGRESS. Every procedure was build on top of another and they were all using one user authentication procedure. One day the authentication server was down and no one could log in, causing the company to be down all night (they had an Australian subdivision using their program as well) with huge losses as a result. A quick fix was introduced, replacing the 100-line authentication script: DEFINE OUTPUT PARAMETER opSuccess AS LOGICAL. ASSIGN opSucces = 1. They forgot about it and only weeks after they fixed it.

Re:seen some bad shit. (0)

Anonymous Coward | more than 5 years ago | (#29198025)

Did this software rhyme with "ebombetry"?

Re:seen some bad shit. (1)

Liquid Len (739188) | more than 5 years ago | (#29198085)

Yeah, well, why bother removing it, then ? If it ain't broken, just don't fix it...

Re:seen some bad shit. (1)

phantomfive (622387) | more than 5 years ago | (#29198113)

Reminds me of one of my professors, when he was in college he had to write his programs on punch cards and take them in to be run in a batch job, then he'd get a printout of the result, debug and try again. Probably from the same time era as your story. One time he got a bug he couldn't figure out at all, but the operator told him, "oh, there are some bad memory segments. Try moving your program around in memory a bit and doing it again." Poor guy said he had no clue how to do it. And I'm glad I don't have to do it.

Thread Manager (1)

ShakaUVM (157947) | more than 5 years ago | (#29197847)

Due to the vagaries of setjmp and longjmp (we were writing a thread manager) and the fact that in C, functions can only return one value we got into a situation where threads (by spec) must be allowed to return an integer, AND the thread manager would need to report if the thread died to the calling function as well (also using the same int). Our group batted it around for a while and didn't see any solutions that were threadsafe under all conditions, so we ended up just specifying that threads couldn't return -1. =)

Cost us 5% off the final grade, I think.

Train simulation (5, Interesting)

LucidBeast (601749) | more than 5 years ago | (#29197863)

Way back we had a project where we had to simulate entire train traffic entering Helsinki train terminal. Someone else had made the simulator and it ran pretty neatly, but unfortunately crashed mysteriously after about four - six hours of simulation time. Our customers were coming the on monday and I spent my sunday trying to figure out how this simulation worked and what crashed it. Finally I caught the problem, which was as simple as some null pointer to a train schedule or something similar which needed to be referenced. I couldn't figure out why it was null in time, so I just added test for null pointer, which skipped said code. Program ran fine and we got our money. Never figured out what was wrong with it. Luckily it was only a simulation.

Study Assignment (5, Funny)

LKM (227954) | more than 5 years ago | (#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.

Re:Study Assignment (4, Insightful)

u.hertlein (111825) | more than 5 years ago | (#29198001)

"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."

This is so sad. He notices your code is faster and he's not the least bit curious? (I presume he's some kind of CS prof.) Anyway, good for you, but still... :-(

Re:Study Assignment (1)

Sique (173459) | more than 5 years ago | (#29198153)

Sometimes you just don't want to know what has beaten/bitten you.

Re:Study Assignment (1, Informative)

dintech (998802) | more than 5 years ago | (#29198309)

Probably he didn't spend much time implementing his version so wasn't too worried. He probably invests most of his time in actual research instead of pesky undergrads.

Re:Study Assignment (1)

hey (83763) | more than 5 years ago | (#29198159)

A good tip. Just output random stuff. Probably how internet dating sites do it anyhow.

Re:Study Assignment (1)

Opportunist (166417) | more than 5 years ago | (#29198095)

I'd sue your prof, he obviously took your program and sold it to various dating webpages now cluttering the 'net."

Re:Study Assignment (2, Funny)

mehrotra.akash (1539473) | more than 5 years ago | (#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....

complex finance math (3, Funny)

Anonymous Coward | more than 5 years ago | (#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.

Re:complex finance math (0)

Anonymous Coward | more than 5 years ago | (#29198161)

That'll be a problem if you ever have to handle extremally large transactions. Doubles round. Finance guys really hate it when their cents go missing.

Re:complex finance math (0)

Sique (173459) | more than 5 years ago | (#29198197)

It might have been some average distances on a random walk (for instance as a model for futural prices or interests). If you wait a time t, then the expected distance from your starting point in a Brownian random walk is ~sqrt(t). And if you look into the past, you might get imaginary expected distances :)

Re:complex finance math (0)

X0563511 (793323) | more than 5 years ago | (#29198259)

The alternative to that dirty hack: finance guy takes remedial algebra

yuck (1)

Ben1220 (1503265) | more than 5 years ago | (#29198051)

yuck yuck yuck keep these stories to yourselves, this is distressing me. If I knew software I was using was coding like this I would feel uncomfortable using it, even if it seemed to be working.

The solution is simple (1)

Sparx139 (1460489) | more than 5 years ago | (#29198207)

Swap to FOSS and change it yourself :p

Who hasn't? (4, Funny)

Opportunist (166417) | more than 5 years ago | (#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.

Everyday (1)

stimpleton (732392) | more than 5 years ago | (#29198321)

Have you ever needed to insert terrible code to make something work at the last minute?

Jesus, every fucking day. Sole IT/Everything guy here.

Yesterday it was enabling the personal IIS service on an XP desktop to get a demo going of an OCR scanner server for a board member meeting, because the scanner on loan would not talk to samba shares. Today I commented out some PHP code that read's a database for a web page and instead pasted in an excel page the admin girl had done. Next year that data will not update automaticaly. I will wait for the inquiry as to why and fix it then. Tomorrow i will FTP the javascript code snippet to our intranet web page that is IE 5.5+ only because thats our work environment....except for the graphics dept....but there is only 4 of them.

For some people, the odd incident are cute, amusing anecdotes. For me, it is everyday in the trenches.
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?