| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: The Alphabet... The Hard Way
2008-03-17 08:04
•
by
OperatorBastardusInfernalis
|
|
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... |
|
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 |
|
Haha. Nice.
|
|
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 |
Re: The Alphabet... The Hard Way
2008-03-17 08:09
•
by
Maybe Anon
(unregistered)
|
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. |
|
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.
|
Re: The Alphabet... The Hard Way
2008-03-17 08:12
•
by
OperatorBastardusInfernalis
|
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 08:19
•
by
snoofle
|
|
You FOOLS!
This person is obviously prepared for the day when they add another letter to our 26 character alphabet - better safe than sorry! |
|
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...
|
Re: The Alphabet... The Hard Way
2008-03-17 08:40
•
by
John
(unregistered)
|
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 ;-) |
One word: Reusability. |
Even so, there's still better ways of doing it. 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". |
Re: The Alphabet... The Hard Way
2008-03-17 08:46
•
by
JimM
(unregistered)
|
Presumably someone did think of a justification for this, because it got written. So why shouldn't we try to think of one too? Sometimes half the fun of a WTF is trying to work out eactly what was going on in the developer's head! 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 ;^) ). |
Re: The Alphabet... The Hard Way
2008-03-17 08:47
•
by
sweavo
(unregistered)
|
Or to their index. Like (symbol) or the numbers. |
Re: The Alphabet... The Hard Way
2008-03-17 08:52
•
by
Maybe Anon
(unregistered)
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 08:53
•
by
c∞l
(unregistered)
|
|
You mean: future pr∞f.
|
Re: The Alphabet... The Hard Way
2008-03-17 08:54
•
by
Maybe Anon
(unregistered)
|
|
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 |
Re: The Alphabet... The Hard Way
2008-03-17 08:54
•
by
disturbedHR
(unregistered)
|
I agree, it's i18n ready. Enough said. |
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 09:01
•
by
tdittmar
|
Or maybe they just knew that the US alphabet isn't the only one around - what about ä, ö, ü and ß in the German alphabet? Or all the other letters in all the other alphabets that are non-english? |
|
That way it at least can be easily reordered. A problem with a simple loop.
|
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 09:14
•
by
JimM
(unregistered)
|
Depending on the justification, it is good. If xml / xslt were the only technologies available, this is as good an implementation as you are likely to see. So the question is, was that the justification for it, and if so why? There probably is a WTF here, but it's not necessarily this code snippet - and since it's listed as a CodeSOD i think that's a bit unfair. A couple of times I've produced a mess of code that was nevertheless a complete triumph over ridiculous adversity thrust upon me by management (a data recording system built entirely in Word / VBA comes to mind...) 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? ;^) |
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 09:33
•
by
mister
(unregistered)
|
|
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+ |
Re: The Alphabet... The Hard Way
2008-03-17 09:33
•
by
Edward Royce
(unregistered)
|
<CFLoop> 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. |
Re: The Alphabet... The Hard Way
2008-03-17 09:36
•
by
Edward Royce
(unregistered)
|
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? |
Re: The Alphabet... The Hard Way
2008-03-17 09:38
•
by
Anonymous Coward
(unregistered)
|
The real WTF is people referring to it as the "US" alphabet. |
|
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.
|
Re: The Alphabet... The Hard Way
2008-03-17 09:39
•
by
s.
(unregistered)
|
The first instance of international system is usually english. Then you add other languages later on. |
Re: The Alphabet... The Hard Way
2008-03-17 09:41
•
by
english speaker
(unregistered)
|
|
<Top Secret>English speakers don't care about other languages</Top Secret>
|
Re: The Alphabet... The Hard Way
2008-03-17 09:41
•
by
Shambo
(unregistered)
|
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. |
|
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?
|
Re: The Alphabet... The Hard Way
2008-03-17 09:46
•
by
Andrew
(unregistered)
|
|
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. |
|
Irish Day without Irish Girl...what has become of the world. :o(
|
Re: The Alphabet... The Hard Way
2008-03-17 10:03
•
by
real_aardvark
|
Well, this year, St Pat's is actually on either 15th March or 1st April, depending upon who you believe. Have faith, little one. |
Re: The Alphabet... The Hard Way
2008-03-17 10:03
•
by
devil's advocate
(unregistered)
|
|
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. |
Re: The Alphabet... The Hard Way
2008-03-17 10:06
•
by
real_aardvark
|
Five letters: YAGNI.
How is this any more i18n ready than a Scrabble bag? |
|
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. |
|
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. |
|
If you're going for code reusability and future proofing, why not just create a structure with any/all letters that are in use?
|
Re: The Alphabet... The Hard Way
2008-03-17 10:22
•
by
Olson
(unregistered)
|
|
Re: The Alphabet... The Hard Way
2008-03-17 10:25
•
by
WhiskeyJack
|
|
|
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.
|
Re: The Alphabet... The Hard Way
2008-03-17 10:28
•
by
JimM
(unregistered)
|
Don't apologise to me - just wanted to check up (I should probably get myself at least a little familiarity with CF - it's not common in the job market yet but I've seen one or two advertising). I'm playing a little bit of devil's advocate here because I still wonder if we're picking on the developer when we should be picking on his manager (i.e. was he lumbered with having to use xslt?), but what the hey... 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 |
Re: The Alphabet... The Hard Way
2008-03-17 10:34
•
by
real_aardvark
|
"In a straitjacket," maybe. "Locked down," I think not. 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.) |
Re: The Alphabet... The Hard Way
2008-03-17 10:45
•
by
s.
(unregistered)
|
Oh, I'm not saying his solution was wrong or worse. I'm just saying it's somehow far-fetched definition of 'easier'. |
Re: The Alphabet... The Hard Way
2008-03-17 10:55
•
by
Shambo
(unregistered)
|
Ahh, yes. Easier is not the word I would have used. |
|
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 |
Re: The Alphabet... The Hard Way
2008-03-17 11:06
•
by
JimM
(unregistered)
|
But "the daily double-plus-ungood" just doesn't have the same ring to it... |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |