back to article You've seen things people wouldn't believe – so tell us your programming horrors

Shellshock. Heartbleed. That CCTV storage firmware with a hardcoded password. We've all seen some really bad code. Maybe that's just me. Given that many of our sysadmin readers have poured in tales of fixing impossibly broken servers for our On-Call series, we know our software-wrangling readers have faced similar battles …

Back in the late '80s, I worked for a guy who had written a program in the Procomm Plus (serial datacomm software) scripting language to collect status data from a group of about 200 network interface devices (Sytek 2502 boxes).

He had a separate loop to collect and store each parameter.

All 53 of them.

It took almost all night to run (if I remember, this was on an IBM PS/2 Model 60, under DOS 3.3), but at least it was ready the next morning for his BASIC program, which summarized and formatted the data and printed a report.

I rewrote the Procomm script into one loop, and it finished in about an hour.

1
0
Anonymous Coward

ASM Write To Buffer Bug

At Uni we had an assembly language course which I was writing a code assignment for and we had been warned by the lecturer to use a virtualised environment like WINE or CYGWIN for running our code because it gave your PC a "protected" environment to work in. Being the cocksure code jockey that I was (I'd written a whole Mode 13h Windows-like UI for a high school assignment the year before so I "knew" assembly) I decided I didn't need it.

First run of the assignment code wiped my HDD boot sector due to not initialising a file write buffer address correctly.

I installed CYGWIN after I'd spent the next 12 hrs trying to salvage the remains of my HDD.

1
0
Anonymous Coward

SWAP SWAP is a great solution

"Lesson: If it smells bad, it's probably bad. See: Oddball Solution."

Someone clueless speak there!

As soon as I saw that, I thought, NOW THAT'S a NEAT way of doing that. I normally would expand the full code, and it looks a big mess.

If you swap individual entries in a loop, then you have 1 loop per swap. If you group swaps together, e.g. 8 swaps, the you're reduced the loop test/jump by 7 making it faster. Then you need to fixup the remainder of less than 8. Which he does very neatly with the SWAPs at the top.

That is genius code, far beyond your level, clearly.

0
0
(Written by Reg staff) Gold badge

Re: SWAP SWAP is a great solution

So - anonymous coward. The last sentence was unnecessary. Be civil.

2
1
Vic

Re: SWAP SWAP is a great solution

That is genius code

It really isn't. And no, I can't telling if you';re being sarcastic, but I do hope you are...

Vic.

3
0
Silver badge
WTF?

More of a design issue than coding...

...but I would like to nominate the design of database applications which require the format of dates to be in the diseased MM/DD/YYYY format.

4
0
Anonymous Coward

Re: More of a design issue than coding...

We have better. Some dates have to be (text) dd/mm/yyyy. Some have to be (text) nn <monthname>. Some are proper datetime fields. Also, some of the audits and logging is in UTC, and some is in local time - in the same database.

A very large number of people directly or indirectly use that code.

0
0
Silver badge

Many mistakes, probably

I'll own up to two, but coding is not my main activity, so it could be worse

1) Never, ever, *ever* do your own date calculations

Years ago I wrote a web log file processor in Python, to track visitors, and do everything webalyser did (except for using cookies) at much less cost, plus various custom stuff. To check log files it took the current date, processed a file, then added 24 hours to the time and looked for that file.

This worked fine for about four months, and then it all stopped working. Co-incidentally, this was the Monday after the clocks went back.. Add 24 hours, still Saturday! Add 24 hours, still Saturday...! Add fix to add 25.5 hours, and use the date functions properly to go to the next day in future.

Don't get me started on people who think they can handle time zones without a library : clue, you probably can't, and yes some places have half hour time zones.

2) Don't believe the specification

Doing nameless things with MAPI and Exchange, my code worked for months and then bombed. Various debugging revealed that it was failing to find a field, hit the exception handler, and fell over because this case wasn't correctly handled. It wasn't handled because the SDK (written by Microsoft), communicating with Exchange (written by Microsoft) informed me that this parameter was 'mandatory' and would always be there. Which it was, until suddenly it wasn't. (I think it was PR_something_RTF - rich text is supposed to be included, but only plain text was in rare instances - a handful of messages out of thousands).

I'd handled errors on every other field - except that one, because it would 'always be there'

2
0
Coat

Repeat Until Perfect

I've spent over 25 years regularly coming back to my software, and doing bits of it again properly this time. The day I'm entirely happy with something I've written, is the day I admit I'm tool old and will retire from coding.

3
0

My first "real job" mess-up

My first job from college was as 'junior operator/programmer' for a carpet manufacturer. My manager was a fearsome ex Midland Bank executive - she was good as gold once I got to know her - and my technical manager Bob, was a really cool ex USAF guy from Colorado.

I was responsible for the end of day and lunchtime orders consolidation batchwork.

ICL ME29 a bit like this https://www.flickr.com/photos/wades_world/4385072758/ with EDS-80 'exchangeable' disk packs for backup. (72MB formatted!!!!)

Anyway, I'd inherited the JCL and CL command files. The command to backup to disc was CRAFTSEC and the command to restore the files was CRAFTREST - note that you can type them with the left hand...

Of course, on the afternoon shift, I typed CRAFTREST instead of CRAFTSEC and overwrote the afternoons data files.

Fortunately, I was able to restore the lunchtime backup and 'roll forward' the afternoons TPMS transaction log files! (once I'd worked out how the system hung together - phew...)

Needless to say, I changed the names of the commands to something harder to type and rewrote the content to something a little more robust on the checking.

Nice machines the ME29's.

reset - enter - load - enter

to reboot it.

LD #ABCD

GO 21

to start a program from the console!

8" floppy discs for loading microcode updates and for me to keep copies of my COBOL programs!

I have a lot of respect for the old-school ICL engineers. The South Wales guys were bonkers, and great company. They really knew how to look after the hardware and the customers.

[sigh] I still miss my ICL VME Series39 machines too! but that's another day...

4
0

Powershell bug

I distinctly remember the morning when I found out that there was a Microsoft feature in early powershell where if a variable returned nul, and you then reference that variable, it selects all rather than nothing.

I had impressivley scripted to set the entire company's Out of Office message to "I have now left the company"

Oh how we laughed....

4
0

HP1000 G-code

In the 1990s I did some maintenance work on a process-control system (HP1000 minicomputers, all of 2MB main memory - running about 100 processes - amazing what one could do in the old days).

One of the original developers had passed into management, which was just as well as while a very nice person had limited coding skills. He had done a lot of the Pascal code in the system, and had fallen in love with CASE - it was used everywhere, almost to the exclusion of IF, and the code was peppered with 100 line long (or more!) CASE constructs. In that system the assembly code was generally much better written, commented, and documented than the Pascal code.

One of the tasks in this project was to move to 50MB disk drives, which meant a different driver set & thus different OS (RTE) memory layout, requiring a complete rebuild of the system from source.

Except - one little time-difference calculation function was missing. So we (myself, another young'un, and the boss) looked at the code that was using it, reverse-engineered its functionality, and re-created it (all of 15 lines IIRC).

However... it was our bad luck that the program on which the big rebuild's compilation had failed was a G-code masterpiece, and when the system went live _every other_ program which used TDIFF was getting wrong date calculation results.

0
0

Re: HP1000 G-code

In the 1990s I did some maintenance work on a process-control system (HP1000 minicomputers, all of 2MB main memory - running about 100 processes - amazing what one could do in the old days).

The old classic HP3000 maxed at around 2MB and often had 4 16-port async cards for terminals. And they invariably used the IMAGE/3000 database built into MPE. So yes, 2MB is plenty of RAM.

0
0
Anonymous Coward

www.thedailywtf.com has it covered

1
0

www.thedailywtf.com has it covered

I wrote to thedailywtf.cm once, a good story. A real WTF!!! It wasn't published.

Until a few weeks later, then a (modified) copy of my tale was published and attributed to someone else. They changed various features, country, names, etc. But it was still so obviously my story.

Never visited that site after that.

3
0
Anonymous Coward

Re: www.thedailywtf.com has it covered

I think they might be doing that to protect the poster from possible legal action.

1
0
Silver badge

Re: www.thedailywtf.com has it covered

Still, sending an email with th edited story (or making any kind of preview available) would seem to be good practice. What drove me away from dailyWTF was the constant horrible misuse of words the writer(s) didn't quite seem to understand.

1
0

How much effort does it take to copy an SQLite database file?

A program we had written by contractors (of course) has data in an SQLite file on an embedded system; this needs to be transferred, in its entirety, over a LAN to a desktop PC. Instead of using anything tricky, like (T)FTP, it made far more sense to them to:

SELECT every record, extracting the fields one by one into temporary variables, convert some to strings, concatenate these strings together, copy this lot onto the end of temporary buffer (re-allocating said buffer everytime it fills), pass it to a home-grown network layer that copies the data into new buffers; rinse and repeat. Finally, a lump of data is sent over the LAN for the receiver to reverse the process and create a shiny new SQLite file.

Cold reading the code and estimating the amount of data being manipulated in the sender, I gave up when aproximately 100 KiB of SQLite file had already turned into multiple TiB of mempy()'s. I thought I'd made some obvious mistake in the cold reading, but running this, you are shown a "Loading..." message for a minute or so, in the middle of which is a very brief burst of LAN traffic...

To be fair, I haven't checked some of the fine details; perhaps the sender and receiver are using different SQL schema and this seemed like a good way to get the data re-arranged...

0
0
Silver badge

Re: How much effort does it take to copy an SQLite database file?

"To be fair, I haven't checked some of the fine details; perhaps the sender and receiver are using different SQL schema and this seemed like a good way to get the data re-arranged"

If you simply copied the file what would be the outcome if it was being updated during the copy?

0
0
Silver badge
Facepalm

Re: How much effort does it take to copy an SQLite database file?

Sounds like the average (which indeed is *very* average) Java programmer left to play. I once worked in a place where one would easily get 50% on the base salary doing on-call support for 6 days every month.

They used MySQL+Java+"stringify eeverything into objects" so, in general SQL is disabled and Java does "select", "sort", whatever. MySQL per design doesn't give a shit about what goes into an INTEGER - et cetera - field, anything is OK, and MySQL will politely ignore any SQL it doesn't feel like doing that day - like DELETE CASCADE.

And Yet - sometimes - MySQL doesn't and pukes and someone like me got woken up at night to fix it.

This unique team of brainiacs also used "util.logging ... ALL" - into a MySQL database of strings(!!!) - as well as logging in various places unknown to logrotate ....

The developers couldn't be arsed to fix any of it, of course, and PHB's opinion was that every brain fart issued in Java was pure platinum dust.

This gooey mess runs a five-nines service used by a multitude of major telecoms globally. One must admit that it does looks really shiny and up-with-the-latest-trending-buzzwords too (as long as one does not peel at the loose paint).

Having been there, I don't trust anything web-based (or IoT'ish), it's all built on brown, smelly, "sand".

PS:

SQLite has a "dump" command. This will lock the database and dump the entire database as textual SQL statements into a file (or socket, I would use a file if possible to minimise the lock time), which can then be transferred by any convenient method and imported on the other end. If someone want to muck with the fields / schema - then the textual SQL representation would be a good place to start, IMO.

6
0

Re: How much effort does it take to copy an SQLite database file?

> if you simply copied the file what would be the outcome if it was being updated during the copy?

SQLite is - from a bit of experience in doing the wrong thing at the wrong time - good at recovering (the incomplete update is ignored and it tidys up, as any good d/b should). Although in this case, as it is the PC that owns & updates the file that would also send the file, it'd be easy to ensure no transactions were pending.

1
0
Anonymous Coward

My most ridiculous bug. While at uni I was working on a 2d side scrolling game, I got it all finished, and the night before it was due to be handed in my PC crashed. On reboot, the project was corrupted, and I had, in true student fashion, not done a single backup.

I worked through the night and got the entire game working again except one problem. the player character wouldn't die. Or rather, they wouldn't lose a life. All the code was there, but in my sleep deprived state I couldn't identify the bug.

onDeath()

{

if ( --life =< 0);

{

gameOver();

}

}

I do not know why, but the compiler we were using decided that, if you have a ; on the end of an if statement, it would decide the if statement was completed, and skip the block below. So my gameOver code was never triggered. And because the compiler thought this was valid code, it was never flagged as an error. I spent over an hour trying to debug a semi-colon of stupidity.

5
0
Silver badge

1 hour --> 2 days

> I spent over an hour trying to debug a semi-colon of stupidity.

A guy I knew spend two days to find such an "extra semicolon after while()" bug. He wept when he realized it.

4
0

Not so much your compiler, as every C/C++ compiler ever made. That is perfectly valid code, although modern compilers will spit out a warning if you enable all warnings.

0
0

True or False

Whilst working in the software department of a well known fruit machine manufacturer, I was introduced to the following piece of logic. I think it was in C, but the gist was:

if(a == true) {

b = false;

}

else {

b = true;

}

3
0
Silver badge

Limited languages.. this was fun to diagnose!

Possibly my first professional coding temporary job (wasn't even at University) was to input and analyse NHS staff workplace injury reasons, plot graphs and suchlike for one particular trust.

The correct way (this was very early 90s) would be to either program it properly, or use Excel. This was the NHS, however, so there was no budget. I had a Compaq DOS PC (486?) - this included GWBASIC, which I probably should have used, but instead it was strongly suggested I use an epidemiological analysis program.

On the face of it, this was a good idea - it was actually quite functional, with input forms, graphing, and a complex interpreted scripting language. I set to coding, and it worked - up until a certain point, when it crashed. It crashed executing a return statement, and analysing the source showed no errors.

The reason I couldn't see an error, was because there wasn't one. The interpreter had a limited stack of statements - as each new line was loaded from the script, the oldest line dropped off the top.. (this was not really documented) The error occurred when the return statement tried to return to a line that was no longer in the stack. Additionally, when the limit of the stack was pushed, it did some slightly odd things.

I ended up using it within that limitation, calling it via menus written in GWBASIC. It was at least in use for a few solid years before it started to hang on a different machine. I was asked back in as a favour, and found that if run under Windows in a DOS Window, and switched from full screen and back again, it stopped hanging and continued. I have no idea why.

Not perfect, but give me a break, it was a summer job whilst I was still at college, and my course was engineering rather than coding.

3
0

The Inscrutable Munge

My favourite comment on a 2-liner in Matlab to seed a rng based on current time:

t = clock;

rseed = mod(round(cumprod([10000,60,60,24,31,12])*t(6:-1:1)'),2^32); % inscrutable munge

(I did once actually figure out what it was supposed to be doing, so not that inscrutable, I guess.)

0
0
Holmes

Abstraction

The easiest things to abstract are faulty logic and premises..

2
0
Bronze badge

So many, but my favorite

was debugging what looked like a networking problem on a multi-player game.

First step: compile with debug enabled, install on one node.

Next step: scratch head as _everything_ falls over.

Look at user code, which did what amounted to a Remote Procedure Call by slopping a struct into a datagram and sending it. The first field of the struct was a function pointer, so the receive routine was essentially

Grab four bytes from the head of the datagram.

JSR to the code at that address, passing a pointer to the remainder.

On return, build a reply packet with the (integer only) return value, and send it back.

This "works" when every node is running exactly the same code. Not so much when foo() on one node is at a different address than foo() on another. Like, say, if the debug compile disables some optimization and code shifts.

4
0

Inhouse defined non documented web framework

A few days ago I looked up an old inhouse defined javascript framework. I was only going to add a simple link, but spent 2 hours just figuring out what files to add, what to call it and how to write sane markup. All was just lookup tables with clueless names.

1
0

UPDATE customers SET LastName='Smith'

3000 customers. All called Smith.

Thank god for backups.

3
0

update

That's a good way to remember doing update inside a transaction. At least then if you get considerably more rows affected than you're expecting you can rollback the transaction.

Also if in doubt, run as select to test while clause before running the update.

Been there done that...especially if interrupted then absentmindedly hit return before noticing the while clause is missing.

3
0
Silver badge
Alert

Re: update

Yep, I too have done a Dreadful ThingTM (DT) with a SQL statement at the command line. Mine was:

DELETE FROM Jobs WHERE JobID = 100572;

I ran a SELECT statement to be sure it was OK, but was distracted and ran:

DELETE FROM Jobs;

It was an Oracle 6(?) database on a small shared server under my desk, so when the curser had not come back after a second or two, I realized I had done the DT and, in my panic, did a worse DT - I hit the big red switch.

Fortunately when I had had a cup of coffee and restarted the server, the database rebuilt itself back to just before the DT. Yes, I know I should have let it run and rolled back the log file, but sometimes you are just stupid...

4
0
Meh

Re: update

Fortunately when I had had a cup of coffee and restarted the server, the database rebuilt itself back to just before the DT. Yes, I know I should have let it run and rolled back the log file, but sometimes you are just stupid...

Ah saved ,by Oracle always being in implicit transaction mode. So it rolled the uncommited transaction back.

If you had done the same, say with Sybase, and hadn't explicitly begun a transaction you would've probably still been screwed as by default Transact-SQL runs in unchained mode. I knew some people who always begun their session with set chained on.

2
0
Anonymous Coward

Re: update

This is the time you discover that MySQL < 5 doesn't support transactions.

0
0

I think I've done it all as well. From early shell scripts that _did_ include 'rm -rf' on some $HOME ( that was undefined). And when I ran it ( as root) , I wondered why it was taking so long to complete.

From the head scratching of trying to figure out what the hell I was trying to do in shell, then PHP, then PERL. It wasn't until years later that I had to start commenting my script ( scripts... always have called them scripts - I was never a programmer ). My debugging skills consisted of inserting 'Print' or 'echo' statements every so often to figure out what everything was doing. OH and I always tested my code 'live' to see who had any issues with it. Ahhhh the glorious late 1980's & 90's!

1
0
Silver badge
Windows

Coding is just like sex.....

...at least that was the conclusion I reached whilst pondering in the shower.

Your first program lights the world up and you are invincible!

Finished so quickly, too!

And it was perfect!!!!!!

After a while the shine wears off when you realise that you are just going through the same moves time after time.

With maturity comes inventiveness.

You spend a lot of time working out new, complicated and obscurely different ways to achieve the same end result from the same starting point.

Somehow it seems to be getting harder and less inspiring all the same.

With age comes increasing disinterest.

Been there, done that, need a bigger T shirt.

Besides, the lead has run out in your coding pencil.

Still, kids of today think that because they have just discovered it they have invented it.

All the've done is invent new names for the same old same old....

10
1

Checking other people's code..

As a Uni Lab tech, part of my job is to help students use our computing facilities. Inevitably, that involves some bug hunting where a student's code is not working, and they are blaming the computer or compiler rather than actually checking their code..

One day, I'd been called over by a student, who was trying to design a website in ASP.net using VBscript (I hated that combination of technologies before this happened, hated it even more after). This website was supposed to provide a way for users to log in and maintain their own personal details. It was also supposed to provide an administrator interface that enabled more functionality for admin users.

It wasn't working. At all. When I looked at the code, it was obvious that the student had copied and pasted the code behind the site from multiple sources. He had also carefully renamed all the variables to prevent claims of plagiarism, and seemingly added more. The trouble is, he really did not understand what they were doing. As a result, he had over 100 variables (estimated as I couldn't be bothered to count), all called things like a1, a2, b1, b2 etc. Clearly what had happened is that he was setting one variable, then reading the wrong one expecting it to have the correct value.

I asked him to go see his lecturer. Not sure if he ever did.

5
0

sscanf .... sh*t scan fail!

Some C-style text parsing code that i incorrectly tried to protect against overruns...

(In a c++ project...)

char tc=' ';

int size=0;

if(sscanf(buf," frame %20d %20c",sizeof(buf),&size,&tc)==2 && tc=='{') {

//Code to parse a frame

}

I am accidentally reading 20 chars into a single allocated char here... Messed up my stack enough to bypass all of my regular crash handling... seriously... stack-traces don't tell you sh*t in this case...

2
0

my $is_valid_email_address = $email_address =~ /@/;

2
0

Can I add a small one here?

Was on an oil rig, commissioning some of the control systems. The problem was that the time needed to be synched between the main system and our computers, and they weren't connected due to firewall rules. So the main controller had a hardwired output set to give a pulse at 00:05. Our computers would then reset their internal clocks when they got the pulse each day. A bit Heath Robinson, but it should work!

So, we set it up, tested it, and went to bed. Come in the next morning, all the times are wrong. By several hours... hmmmm

Spoke to the guys, they checked it, and said there was nothing wrong with their system. OK, so I reset all the clocks (slightly wrong) and stayed up till midnight to check it again. Everything seemed to work, and I went to bed. Next morning, everything is screwy again.

So, I go to the softies office to complain. They pulled up the code on the screen to show me that it was very simple and couldn't possibly go wrong. Basically it was:

IF $HOURS + $MINUTES = 5, send pulse.

So I had to point out to them that this would indeed send a pulse at 00:05, but also at 01:04, 02:03, 03:02, 04:01 and of course 05:00. There was a small silence...

10
0
Gold badge

I was once awestruck by a piece on the old System/38, while looking for a problem that had come up.

It was a CL program.

It had 25 lines.

Most of these were comments on what the thing did, leaving three lines of actual code.

Two of those were "PGM" and "ENDPGM".

That left one.

Which was wrong.

On the plus side, it was quite easy to find the error.

4
0

Uninitialized variables

When Sun introduced shared libraries in, I think, SunOS 4.0, dozens of standard unix utilities and probably thousands of user programs failed, all with essentially the same bug.

In C, local variables are not initialized by default, but at program startup the stack would be full of zeros, so that local variables in main() at least would be zero, and many programs inadvertently relied on this. But when shared libraries came along, the dynamic linker ran before main() was called, and the stack no longer contained zeros.

Of course, more modern compilers will generally warn about uninitialized variables.

2
0
Silver badge

Not knowing what your coding in is a good one!

I do a lot of full blown web to DB stuff and, being disinclined to make more work for myself than necessary often use a lot of stored procedures on the DB end to make things more OO where I can. I also write a lot of things to build and rebuild most of my code/db for me.

Normally works pretty well until some bright spark at Postgres decided to make stored procedures overloadable - or maybe I'd never noticed before. All the tests ran OK, the code was fine until the DB procedure started returning shit - even though the tests on 'those' procedures ran fine.

Spent about a week thinking I was going insane and very nearly doing so until I ran one of those gui db frontends and saw lots of procedures with the same name.

So another load of checking added to the show...

1
0
Anonymous Coward

These are just some of the horrors I've uncovered from one vb.net dev.

1. Always uses global variables when passing data between classes and forms.

2. Uses global functions everywhere - no shared or static methods for this guy.

3. First line of source code is always 'Option Explicit off' and the second 'Option strict off'

4. Still uses vb6 database code instead of the sqlclient - it worked 15 years ago so why change it.

5. Favourite statement - 'I don't have time to add error checking!' - it's one extra line of code ffs.

6. Picturebox used to load and hold images temporarily - last time I saw this was in vb6.

7. DoEvents - need to pause something on a button why not sit in a loop and call doevents continuously - queue 100% usage on the processor.

8. One timer used to fill global variables and another timer to use them with no code to check if either has in the correct order.

9. Need to combine two byte arrays - easy convert them to ascii strings and use string1+string2 and then convert them back using loops and ASCII / CHR functions.

2
0

Because that is how you can tell if a number is negative...

My fave ever https://twitter.com/MarcosBL/status/641110424193232897

static int isNegative(float arg)

{

char *p = (char*) malloc(20);

sprintf(p, "%f", arg);

return p[0] == '-';

}

1
0
Anonymous Coward

I once bricked an NT4 Exchange server, when a insistent manager persuaded me to defrag the information stores OOH. I wrote a batch file, tested it, it worked great. It stopped the services, cleared some disk space, defraged every thing, restarted the services. Job done.

On Friday evening I scheduled the job, and went home. And then the phones started ringing on Sunday when people complained that the Exchange server was down.

On investigation, the NT4 server was very poorly. It blue screened, and resulted in a total rebuild, the raid sets needed recreating, NT4 was reinstalled, Backup exec reinstalled, and restores performed. Nightmare. It took over 36hrs to recover.

The cause: At the start, the batch file did a del *.* in the folder where the batch file was running from. All well and good during testing as the batch file itself was R/O. However, when the scheduler ran the batch file, the parent directory was no longer the folder where the batch file resided, but the instead it was the C:\WINNT\SYSTEM folder. Hence the OS allowed all the unlocked files to be deleted, eventually leading the OS to BSOD and the box to die.

Not my finest moment, but I did get double time for working all Sunday to restore the damn box ;)

4
0
Anonymous Coward

What about the Mars Climate Orbiter?

The Mars Climate Orbiter was lost because of "ground-based computer software which produced output in non-SI units of pound-seconds (lbf s) instead of the metric units of newton-seconds (N s)"

1
0

Worst date to string conversion routine... ever?

A few days after starting a new contract at a city stockbroking firm in about 1991 where the permanent 'programmers' all wore very stripey shirts and braces, I stumbled across a module about 20,000 lines long (VAX Pascal) that had the sole purpose of converting date values to their string representations for display.

Now, any decent programmer knows that you can do this in a few lines by breaking the date down, assigning the parts of the date their string representations and concatenating the result together but.... the code I found looked essentially like this (pseudocode):-

IF Date == "01/01/1970" THEN

OutputString = "1st January, Nineteen Seventy"

ELSE IF Date == "02/01/1970" THEN

OutputString = "2nd January, Nineteen Seventy"

ELSE IF Date == "03/01/1970" THEN

OutputString = "3rd January, Nineteen Seventy"

ELSE IF Date == "04/01/1970" THEN

OutputString = "4th January, Nineteen Seventy"

..... etc. etc,. etc..

And it went on like for every date up to the year 2020! :D :D

Needles to say I didn't renew that contract!

3
0

filename parsing

prime example of bad code :

A filename parsing routine that, anno 2016, still looks at the last three characters of a file to figure out what type it is and then send the file off to a preview handler.

So if i send a file called document.doc it thinks 'word document' -> send ot handler

if i have a file called document.pcbdoc it also thinks 'word document' which irreparably corrupts this file as it is a CAD (pcb layout) file.

the correct way would be to reverse scan the string for the first occurence of the period (.) then scan forward and use that.

Who does that you ask ? Bloody damn google drive. Whenever i upload a .schdoc or .pcbdoc google drive thinks : this is a word document. Even worse : when downloading it changes the extension to .doc totally corrupting the project tree. Thanks for nothing google.

6
0

Page:

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Forums

Biting the hand that feeds IT © 1998–2018