Forum Moderators: coopster

Message Too Old, No Replies

Your ugliest kluge ...

disgust us with code you wrote that only a mother could love

         

mincklerstraat

7:25 pm on Nov 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working something and have again gotten myself into the situation of coming up with a solution that is such a bass-ackwards way of solving things that it'll go down in my personal history of one of my very ugliest kluges.

I am willing to divulge certain details of this kluge, but since I never go out in public naked alone, will wait to see if anyone else first posts a gem of a nasty kluge.

No really lengthy code dumps please; descriptions can be ugly enough.

jatar_k

1:52 am on Nov 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> go down in my personal history of one of my very ugliest kluges

lol, until next time ;)

I really can't remember specifics about any but I know there have been some nasty ones. Had to give shell to the web user for a while once, that was pretty ugly.

bobnew32

5:31 am on Nov 14, 2004 (gmt 0)

10+ Year Member



Designing an entire website with include urls and just urls that were static. So once I moved the website, I had sooooooo much changing to do to change the links :(

Deab

11:10 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



Anything I wrote 3+ months ago seems a horrible mess whenever I go back to it. Probably due to the fast learning curve with php, but its very satisfying returning to and rewriting old code.

Salsa

12:28 am on Nov 15, 2004 (gmt 0)

10+ Year Member



Everything I've written before today. Does that mean I should dread tomorrow? Somehow, I don't. Weird.

Hmmm... (being philosophical)... Ever notice whow weird weird is? It doesn't follow the "i before e, except after c" rule. Weird.

larryhatch

12:51 am on Nov 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Omigosh! All my earliest pages, HTML now, no PHP.

I was just so happy to see ANYTHING render. To clean
things up, I removed all those silly things at the top
that made no sense to me, you know, Doctype, charsets,
all that silly stuff.

You can imagine the fun I had validating those pages
later.

- Larry

benlieb

5:46 am on Nov 15, 2004 (gmt 0)

10+ Year Member



I've written some rediculous code trying to have php output javascript.

The most notable rediculousness was sentences with "quotes" in them from a database, and echo-ing them into onmouse events, that would then load dynamic urls. A total mess. The quotes wreak total havoc and I still cant get them to work 100%. I've try htmlentities, special chars and other nonesense.

I wish php could be set up to take other symbols as string markers. Ones that never appear in "real" language.

mincklerstraat

9:07 am on Nov 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, I am so shocked and disgusted! What ugly, ugly kluges!

Ok, here's mine. I've got this php config file that I want to change every once in a while, and each time it's changed it'll only change one entry. I could have used the PEAR packgage Config, but thought, why bother learning how to use this new class, with all the extra bloat? I also didn't want to bother writing something to put the config file together - so I just made a function to find the place where a given variable or element in an array is set; the script reads in the file, locates that line, replaces it with the new config value, writes the it all to the file. Real smart, right?

Then I realized that some of the variables I was needing to change were elements of an array, of which there were more than one array using these element names. So I add comments to the config sheet to help 'localize' the arrays, and write another function to find the parts of the code that's inside these functions;

So now what this code does is read in the file, find the array needed as $arraysnippet, find the line in $arraysnippet that needs to be changed, and replace this in a copy of $arraysnippet called $newsnippet; It then replaces $arraysnippet with $newsnippet, and then writes the file.

If I'd just used the pear class, it would have simply been a matter of listing which variables I had in this sheet, modifying the ones I wanted modified, and sending these to the class; the config sheet would just be made again from scratch, all done by the class. As it turns out, I'll have to write something to produce the config sheet from scratch anyways since if an error ever creeps into the config sheet, as it's now written, the error will be reproduced in the modified config sheet.

Salsa: Neither leisure foreigner seized the weird heights. Remember this sentence and you'll have most of the exceptions.