- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Maintainable shmaintainable!
Admin
The horror...he's using + to concat strings in SQL when everyone knows it's ||. Then he escapes quotes with \' when everyone knows it's ''.
That's the WTF, right? ;-)
Admin
I would say they should bring that code to the CTO's boss to see if they can get rid of him, but if the CTO made it that far up the ranks I can only imagine what the CTO's boss would produce for his "The "Now That's a Neat Trick!" code.
Admin
Needs more Javascript.
Admin
You know, The Cleverness Scale isn't a bad way to predict quality...provided you view 1 as the highest score and 4 as the lowest.
Admin
It's not that simple. Sometimes you have to do a 2 or a 3 in order to fit 2 values into one register, or one ioctl argument, or use certain Windows SDK functions as designed and documented (ugh). When the choice is between cleverness and brokenness, clever wins every time!
Admin
I recall a WTF being featured in this space not that long ago where the web page rewrote itself, or something to that effect, and we all mocked it. Apparently, we just don't recognize true cleverness when we see it ;)
Admin
Multi-Tear architecture.
Admin
Because we all know that code that is impossible to maintain, barely readable, and borderline functional is always better than straight-laced "by the book" code as long as it's clever!
If anybody tried anything rating above a 1 on that scale, they'd be fired at most places, and thankfully so. How this guy got to be the CTO is a real mystery, or at the very least, how he got the idea that he had enough skills to "show the developers how it's done." Eeesh.
CAPTCHA: paula; seems oddly appropriate for this one.
Admin
That recalls me of something I've read here:
"It could be worse, imagine if this guy knew about XML..." :-)
Admin
I don't ever want to score a 2 or higher...
Admin
Actually, that's not always the case. Admittedly, most of the time I take the simple-to-understand-and-maintain-so-I-can-hand-it-off-and-move-on approach, but there are those (usually) rare occasions when true cleverness and programming slight-of-hand are required. The trick is to know the difference.
Admin
Definitely clever to the max... if anyone ever wants to change something in that, the easiest, fastest, most secure way would be to completely rewrite it.... unless you wrote it in the first place..... Brillant....
Admin
Javascript never really was "pretty" was it. Maybe once, for a day or two.
Do I really need to change my rss settings :(
Admin
Is this a N-Tear architecture?
Admin
The Real WTF(tm) is that the clever query is hardcoded. Should be an http query parameter. Now that would be neat trick.
;-)
Admin
More mistakes are made through cleverness than have ever been made through stupidity.
dasmb (a dumbass)
Admin
I've done a 2 once in a while--sometimes, you're constrained to reuse an int32 to store two int16s. But yeesh!
Admin
Looks like uNi-Tear
Admin
The quotes are for PHP's benefit, not SQL's. PHP is the outermost layer (someone has to run that SQL after all). SQL isn't going to care about double-quotes when it's opened with single quotes. I've never even heard of || to concatanate anything, short of incredibly painful C++ operator overloads, but then I'm no SQL guru.
I guess technically the HTML's still being done at the PHP layer... even if it has to take a round trip through the database first. o.O
Admin
Doubtful.
Admin
Question. Is the CTO Michael Scott of Dunder-Mifflin (Scranton Region)?
Admin
union address
{
int32 location;
int8[4] sub;
}
This way, the 32-bit address could be manipulated using simple mathematics yet be passed to the SPI bus as the 8-bit numbers required by the M25PX0.
For example, after saving a 10-byte value:
address.location += 10;
And when writing to the SPI:
SPI_WRITE( SPI_WRITE_ENABLE );
SPI_WRITE( address.sub[ 0 ] );
SPI_WRITE( address.sub[ 1 ] );
SPI_WRITE( address.sub[ 2 ] );
Admin
I've never even heard of || to concatanate anything,
Allow me to introduce you to PostGreSQL, which uses it for concatenation of strings.
Admin
Holy God..the bad thing is that I have to live with several more people of this species.
and ... Too bad the CTO seems not to know Bash scripting. I guess SQL code generated in bash (with backslashing, yeeeah) would receive level 5 rating..
Admin
I'm afraid that example only gets a 3 in my book. The use of INNER JOIN is in no way clever. Surely, he could have come up with a neater way to waste time.
Admin
"it turns out that there's some sort of relationship between clever code and incredibly painful maintenance"
Someone, and it may have been Dennis Ritchie, but if it wasn't it was another one of those Unix guys, once observed that debugging is twice as hard as writing code in the first place, so if you write code that's as clever as you know how, by definition you're not going to be able to fix it.
Admin
Eh? I don't see any +'s in the SQL code.
Where is the PHP, by the way?
I would guess this code was once again anonymized from relative WTFness into SUPER WTFness.
Admin
How is this "clever"? The main sin I see is mixing more HTML + JavaScript than is needed (could have made more use of JS functions, or styles instead of colors).
What I define as "clever" is the massive barely-documented n-tier superstructures that are employed for the most trivial of apps. Sometimes, the simplest solution works the best, and sometimes that's a plain old SQL query.
Admin
He was probably demoted upwards.
Admin
$sql = "
SELECT
CONCAT(
Admin
You know I think the terminology for the CTO being where he is is rather incrongruous and at worst shamefully true. He got to where he is today via a combination of 1) the good 'ol boy network, 2) he *knows* information technology, and 3) just plain shmoozin' with the suits dear wives at a shin-dig on a weekend. We all know and understand that he's a complete idiot when it comes to 1) actual code writing, 2) implementation of an project (on time and under budget) and 3) testing for completeness in regards to those pesky user requirements.
WTF? he's only doing what he *thinks* is right so why bother pointing out to him he's a blathering idiot with a paycheck 94 times the average programmer with no justifiction for such a high salary and that since he is the CTO trust him.
Admin
What? No XML?
Admin
At least the CTO wasn't hoping to get rid of all that JOIN stuff.
Admin
Now THAT is clever!!
Admin
That's much like my scale:
1 - "Good"
2 - "Interesting"
3 - "Clever, but wrong"
4 - "I never would have thought to do it that way"
Admin
If you have never read The Peter Principle you must. It continues to hold true!! I have seen examples again and again (in my 30+ years working life).
Admin
Okay, I get sick of developer egos sometimes, but the hubris of this guy to think that THAT is good code? WTF?
It's easy to program and (generally) solve a problem, but do people just stop learning and thinking when they get just far enough? And of course it's our job to work with or clean up code like that. They should at least be smart enough to take a step back and let the professionals do their job. (I know, I'm asking too much.)
*sigh*
Admin
Haha!
Admin
I've never even heard of || to concatanate anything,
Allow me to introduce you to PostGreSQL, which uses it for concatenation of strings.
Same in Oracle. || is the concat operator.
Admin
IMO 2 is by far more tricky than 3. 3 is almost normal in the age of HTTP and XML.
Admin
Mixing HTML and Javascript is fine. Mixing HTML and Javascript inside SQL is the sin.
Seperating your application into data, logic and presentation layers is just good practice. If your application reads, processes and displays data it is probably sufficiently complex to warrant these layers.
You should always be able to alter the apperance of the site without worrying about corrupting your data and logic.
Admin
Indeed, "good enough" is a common theme in our business. Unfortunately, because everything seems to change every single day, sooner or later everyone of us has to say "ok, enough learned, now let's try to do something usefull".
Admin
Aww, come on! That code isn't so bad. If he had only used styles, it would be possible to alter the presentation somewhat.
So you say it's not maintainable? I don't know about that? You can look at the code pretty briefly and get a good idea of what it does, which is probably more than you could if it were abstracted away in layer upon layer of indirection.
And even if it isn't maintainable, that code is so brief that you can afford to write it once, and if you ever need to alter something, throw it away and write it anew.
Sometimes you can spend weeks and months building up a service-oriented, multi-tiered, abstract, open standards, bells-and-whistles framework, and if all you need to do is produce a simple report then you've grossly over-engineered the solution.
Admin
Nope, even if you were the original author, rewriting it is easier, faster, and more secure.
Admin
I love it!
Admin
this is one of the worst ever.
Admin
If you do it that way, endianness will bite you. There's no guarantee that sub[0] is the low byte. This might not matter if you're writing for specific hardware... but even hardware is hardware-independent these days. PCI cards can be plugged into PowerPC machines.
It's best to write some macros that use >> and & to extract specific bytes.
Admin
There. Fixed that for you.
Admin