- 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
Först, and this XSLT code at least checks if there are items for each letter. I don't know XSLT enough to judge if there would be a simpler way to do that... but of course, it could be easier done in other languages.
But maybe there was a specific reason to do it in XSLT...
Admin
Well that approach allows to adopt to changing alphabets. What would you do if the ASCII Standard would change without warning? With this XML approach the solution is very simple.
Todo: Dynamically generate the alphabet file with the most current alphabet data, possibly using SOAP
Admin
Haha. Nice.
Admin
Hee hee, If I had a dollar for every time I've seen this kind of waste (well, I'm in the US, so my dollars would buy a lot less these days.
Anyway, when the only tool you have is a hammer, everything looks like a nail.
Cheers, Ted
Admin
No, no, no, no. Your doing it all wrong. Don't even THINK about how you could possibly justify this.
I'm going with Paid By The Line. This is just plain stupid.
Captcha: Feugiat - I bet you wouldn't say that to my face.
Admin
I've worked with xsl for a number of years, and yes doing very simple things can be this tedious and insane, especially when the real programming is done elsewhere by someone else. Believe me, there is no concept of ascii codes in xsl. It is possible this developer had access to exsl tokenize and could have for-eached a tokenied alphabet, but there's nothing here to suggest tokenize was even available.
Admin
Well, MAYBE this is static content, and the XSLT is processed by the web browser - so the website would have an XML file with that info on the server, and serve it in full, together with a style sheet that does this processing?
In any other case, I'd opt for a server-based solution that does this processing - it'd be for sure more efficient than this XSLT mess.
Admin
You FOOLS!
This person is obviously prepared for the day when they add another letter to our 26 character alphabet - better safe than sorry!
Admin
Sure, the implementation might be a bit whacky, but the idea is good as it allows for supporting different alphabets - The US alphabet isn't ubiquitous, you know...
Admin
That's right. I mean W replaced double U 'uu' so what if they make a new letter like double o (they could use the infinity symbol), err, did you think about that? Clearly the XSLT approach is to "future proof" the implementation. Really people, come on, think big picture... and don't be so quick to ridicule what is obviously a fantastic design. You lot must be real thick o's ;-)
Admin
Admin
This strikes me as someone who skipped over the basics and went direct to the cool sexy Enterprisey stuff. I'd hate to see their implementation of "Hello world".
Admin
I can think of at least 2 reasons for writing somnething like this: the developer only had experience of XSLT, or the developer didn't have access to any other tools (i.e. no server-side scripting). This could even have been a proof of concept for a pure xml application. In fact, this seems to be listed as a wtf simply because it utilises an unusual and non-optimum set of technologies. The fact is that, regardless of the suitability of the technology used, this is a fairly good attempt at an implementation (for instance, it doesn't create the links for unused letters) and you could not reproduce all the functionality expressed here in three lines of code (you'd need at least four or five ;^) ).
Admin
Or to their index. Like (symbol) or the numbers.
Admin
The point isn't that you can't justify this, it's that some people seem to be trying to show that it's good.
I'm all for retracing the steps that lead to the madness, but some of the replies here look like they are starting to think it's actually a good idea and the developer needs karma.
For those with broken sarcasm detectors - the developer needs retraining.
Anyone who thinks lugging around these 100 lines of code (guestimation, I'm sure someone will count them for me anyway) provides MORE reusiblity than a 3 line loop in a method may be missing the point.
Admin
You mean: future pr∞f.
Admin
Look - <xsl:if test="starts-with(surname, $alpha)">
It's for NAMES. People will NOT be using this system when people have to resort to be called bill #999-doe
Admin
Admin
Depends on definition of 'easier'.
We had a case like this recently. One of our team is an old-time hacker we find hard to understand at times. He was writing a piece in Perl and stumbled upon a problem: two different system libraries provided some getters and setters. And he needed to get one value and set it elsewhere. Essentially:
setObscureValue(getDifferentValue($index));
The line above didn't work. OTOH:
$temp = getDifferentValue($index); setObscureValue($temp);
did. "Likely, setObscureValue takes a reference, not a value, and it doesn't like reference to a call to a function." we guessed. "Just use the temporary variable if it works."
His answer?
"No, I'll do it the easier way. I'll check the sources of the libraries."
Two hours later he ended up finding that indeed the function requires the reference and used a temporary variable as a solution to the problem.
Admin
Admin
That way it at least can be easily reordered. A problem with a simple loop.
Admin
TRWTF is someone that obviously hasn't a clue about XSLT calling this a WTF.
This is, in fact, the only way to do it in pure XSLT without resorting to extensions that may or may not be available.
Admin
Based on the hrefs for the links the rest of the site is coldfusion, and I have to admit a complete absence of knowledge about cf development. Any cf developers available to let us know the right cf implementation? ;^)
Admin
From what I’m seeing in the xsl, the result should be a list of name ordered by alpha. So guys, I'll let you in on a little secret:
<Top Secret> English is NOT the only language in the world</Top Secret>. If you trying to create a "phonebook" that would work for more then just plain English then looping on the ASCII code is just not going to cut it.
Ditching a solution without knowing his requirements is just plain stupid.
Admin
Correct. We don't know the requirements, maybe it was some kind of "do it in xml/xslt ONLY). You don't always the best (or the non-worst) tool available.
Hey, if you want to do a 'Hello world!' program, you might as well refuse to do it on anything besides HQ9+
Admin
I.e a 3 line loop incrementing using ASCII decimal values.
Sorry man. But I can't think of an instance where a CF programmer would do things this way.
Admin
If this code was supposed to handle internationalization then ... wouldn't it already include an example of it?
It's straight English alphabet. I don't see an umlaut in there. Do you?
Admin
Admin
It's a solution for the Year 3078 problem. You know, when we run out of possible combinations of 26 letters and have to make changes in order to continue our current rates of word generation. As you know, Bob, the introduction of verbing (assignment of verb functions to nouns) in 1987 bought us some time. But we need to be ready.
Admin
The first instance of international system is usually english. Then you add other languages later on.
Admin
<Top Secret>English speakers don't care about other languages</Top Secret>
Admin
Let me get this straight, you used trial and error to get a response which "looked" correct. He actually cracked open the library and traced the error down to find out exactly why it occurred. I would have to side with him on this one.
Admin
Look like they're using ColdFusion. I've never worked with it, but surely it supports loops and such in a way that is less tedious than XSL?
Admin
Okay, but then you loop for the 26 chars, then do each symbol seperately.
That's maybe 4-6 extra lines, much less than this mess.
Admin
Irish Day without Irish Girl...what has become of the world. :o(
Admin
Admin
perhaps there are many different XML files for the many different language alphabets in existence today. you see, in the real world people speak, read, and even write in languages that are different than english, and those languages often have completely different alphabets. Could you possibly foresee a situation in which a company may have a need to support more than one language?
that being said, this solution is dumb...just wanted to argue a point.
Admin
Admin
Can we assume that if support for non-English characters was in the spec, then it would have also been in the implementation?
OK...
Try to justify it all you want, it's a clear case of a PHB reading about XML/XSL, thinking that's the only way to do anything nowadays, and demanding that everything be done that way from now on.
The developer in question is either bowing to management pressure or (more likely) trying to show it up for how ridiculous it is.
Admin
I had to refactor this recently... I think it was a case of "USE XSL, it's easy - you don't need to RTFM".
That's only scratching the surface of what was wrong with the files.
Admin
If you're going for code reusability and future proofing, why not just create a structure with any/all letters that are in use?
Admin
Admin
Admin
One possible reason for this, might be that the actual system is locked down. Perhaps this is a CMS or a shopping cart solution, where you can't touch actual code. The only way you can do something, is making HTML templates using XSL.
Admin
Oh, and whoever said the devleoper is "bowing to management pressure" - it's this thing called a paycheck. Some of us like having our own roof over our head, rather than our parent's house... ;^p
Admin
Algorithm + Data Structures = Program.
Templates aren't some kind of weird, side-effect-free, magic, y'know. (With the possible exception of MVC-style templating, which hardly applies to anything written with XSLT.)
Admin
Oh, I'm not saying his solution was wrong or worse. I'm just saying it's somehow far-fetched definition of 'easier'.
Admin
Ahh, yes. Easier is not the word I would have used.
Admin
I see several comments about adding letters, but no one seems to have considered the opposite possibility. What about removing letters? C is adaquetely covered by K and S. Q can be covered by C (K) and KW. We can bring the number of letters down to 24 without much work. Of course, that means double ROT-13 will not be as secure, but we can always go to ROT-12.
captcha: valetudo
Admin