Mysteries of the Universe

Oct 05, 2013 13:57


There really needs to be a corollary to Newton’s Second Law of Thermodynamics, stating that website maintenance is a constant (and un-winnable) battle against the Stupid introduced by other people.

Usually this involves a lot of quiet fuming while cleaning up the garbage left behind by the incompetent agents of entropy. But sometimes the Stupid is just so ludicrously headdeskingly perfect that there’s nothing you can do but laugh until you gag on your own puke. All the while, marveling at the “mysteries of the universe”.

For example, consider the following. While working on something, I once came across the following block of code on a production website:

$rss_feeds = ""; echo $rss_feeds;

Now, even if you’re code-illiterate, you can probably figure out what this does. It sets a variable to nothing and then prints… nothing.

Why? No reason. The only thing I can figure is that someone hired a contractor and paid them based on the sheer number of lines of code they produced.

Now, before I lose all the non-coders in the audience, here are a couple examples where people chose to demonstrate their mastery of their native language. For example, take this headline that appeared in a second-level heading on one page:
Private vs. Gevernment

Or this major announcement:
Without further adieu [...]

Or this favorite job listing of mine:
[...] is currently seeking a Senior FrontEnd Web Developer with 710 years of professional experience

Working our way into the code doesn’t have to be painful, though. How about this one: Need to name a file? Why not name it after your own awesome self?

$fileExt = 'markrules';

Another one that is easy for non-coders is this one:

Yup. In the Stupid Universe, left is right and right is left.

Now how much would you pay? But wait: there’s more!

In PHP, two slashes are used to comment something out. So here we have a line of code carefully commented out. And then the exact same line, not commented out. Um… huh?

Speaking of comments, try figuring out what this one does:

$form->addElement('hidden', 'xzdf', 'A3104', array('id' => 'xzdf'));

Using names or key values with self-evident meanings is really overrated. The Law of Stupid instructs us to use completely nonsensical names, and make sure you don’t leave any comments in the code that might explain to the people maintaining your code what those random numbers and strings of characters actually mean!

And then there’s this mystery of the universe, a perennial favorite:

$term = ereg_replace("hero", "elongated sandwich", $term);

I can’t tell you why this site has such a strong aversion to heroes, but it’s clear that any time we find the word “hero”, we replace it with our preferred term “elongated sandwich”. No reason; we just do. No hero worship allowed here!

Here’s a fun one!

.blue_button {     background: none repeat scroll 0 0 #ED8D1E; }

Blue_button, huh? You might be forgiven if you thought that might actually show a button that was blue. But that background color of #ED8D1E? That’s dark orange. OF COURSE!

For some reason, “switch” statements seem beyond the grasp of many well-compensated “engineering professionals”. I’m not sure why it’s so difficult to do different things depending on whether a variable has a value of 1 or 2 or 3, etc. Is that so hard? Apparently it is. Here’s a nice example:

case 1: $url = 'http://www.awebsite.com/'; break; case 1: $url = 'http://www.awebsite.com/'; break; case 1: $url = 'http://www.awebsite.com/'; break; case 1: $url = 'http://www.awebsite.com/'; break; case 1: $url = 'http://www.awebsite.com/'; break;

That’s a double dose of Stupid! Here, all the cases do exactly the same thing! But that’s okay, because they all test against the same value, too!

In plain English, it translates thus: if it’s a 1 you do this; but if it’s a 1 you still do this; or if it’s actually a 1 you would also do this; and if 1 you do the same thing too; and so on. That’s seventeen lines of code to do what requires only one. See what I mean about someone being paid per line of code?

Of course, that only works if you want to do something. Truly masterful Stupid code does nothing, like this switch statement:

switch($page[subnav]) { }

Huh. Only outside of the Stupid Universe is it customary to write code to actually *do something*.

Of course, junior developers often aren’t wise enough yet to disguise the fact that they’re doing nothing. Consider this:

Yes, that’s nothing. That’s the whole contents of a file I found called small.css. Small, indeed! Perhaps they thought they weren’t leaving any evidence of their stupidity behind.

Here’s some additional CSS-flavored fun:

More from the Planet of the Confused: why not just do “clear:both”? Oh yeah, it’s because YOU HAVE NO IDEA WHAT YOU’RE DOING!!!

ttable tr td.odd { border-left: 0; border-right: 1px solid #fff; }

Did the W3C create a new HTML tag (ttable) and I missed the news?

p.margin-left {margin-left: 15px; padding-right: 15px;}

So let me get this right: a paragraph called “margin-left” actually has equal margin on both sides? But on the left it’s a margin, and on the right it’s padding? That makes perfect sense, especially if you don’t understand basic HTML page layout!

Here’s an exemplary 12 lines of masterful coding:

if (isset($page_close)) { $page_close .= << EOD; } else { $page_close = << EOD2; } echo $page_close;

That’s just another example of how these guys clearly were getting paid per line of code. No matter what $page_close is set to, what those 12 lines of code really do is this:

No need for complex logic or any dynamic behavior. Good thing they inserted an extraneous IF/ELSE block, two “here quotes”, and echoing a variable, because how else would one know they were such masters of PHP syntax?

if (test_it_counter == 0) { computeForm(entry.form); } computeForm(entry.form); test_it_counter++;

So the first time through this program, computeForm() get run twice in a row, just for kicks. I’m sure that works just great! I wonder why they didn’t run it twice every time?

I have absolutely no idea what the coder was thinking here. If you hover over a nav, it displays a tooltip with a bunch of CSS code (which actually doesn’t get used and doesn’t appear anywhere in the page) and the message “note the hover action”. Glad that has been running out on the production web site for four or five years…

My final example is a solve-it-yourself problem. Are you ready for a developer challenge? How long does it take you to spot the Stupid in this statement?

This one’s an all-time classic and a personal favorite. When comparing a variable to a literal, professional software engineers always put the literal first. Do you know why? Well, the above is a perfect illustration why. The reason why will be left as an exercise for the reader.

english, programming, logic, stupidity, css, language, html, career, spelling, humor, stupid, coding, job

Previous post Next post
Up