• (cs)

    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...

  • SK (unregistered)

    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

  • Mark (unregistered)

    Haha. Nice.

  • Ted (unregistered)

    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

  • Maybe Anon (unregistered) in reply to OperatorBastardusInfernalis
    OperatorBastardusInfernalis:
    [snip]

    But maybe there was a specific reason to do it in XSLT...

    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.

  • Ben (unregistered)

    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.

  • (cs)

    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.

  • (cs) in reply to OperatorBastardusInfernalis

    You FOOLS!

    This person is obviously prepared for the day when they add another letter to our 26 character alphabet - better safe than sorry!

  • Fredrik (unregistered)

    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...

  • John (unregistered) in reply to snoofle
    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!

    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 ;-)

  • (cs) in reply to Maybe Anon
    Maybe Anon:
    OperatorBastardusInfernalis:
    [snip]

    But maybe there was a specific reason to do it in XSLT...

    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.

    One word: Reusability.

  • (cs) in reply to Fredrik
    Fredrik:
    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...
    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".

  • JimM (unregistered) in reply to Maybe Anon
    Maybe Anon:
    OperatorBastardusInfernalis:
    [snip]

    But maybe there was a specific reason to do it in XSLT...

    No, no, no, no. Your doing it all wrong. Don't even THINK about how you could possibly justify this.

    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 ;^) ).

  • sweavo (unregistered) in reply to snoofle
    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!

    Or to their index. Like (symbol) or the numbers.

  • Maybe Anon (unregistered) in reply to JimM
    JimM:
    Maybe Anon:
    OperatorBastardusInfernalis:
    [snip]

    But maybe there was a specific reason to do it in XSLT...

    No, no, no, no. Your doing it all wrong. Don't even THINK about how you could possibly justify this.

    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 ;^) ).

    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.

  • c∞l (unregistered) in reply to John

    You mean: future pr∞f.

  • Maybe Anon (unregistered) in reply to sweavo

    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

  • disturbedHR (unregistered) in reply to Fredrik
    Fredrik:
    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...
    I agree, it's i18n ready. Enough said.
  • s. (unregistered)

    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.

  • (cs) in reply to snoofle
    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!

    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?

  • Vollhorst (unregistered)

    That way it at least can be easily reordered. A problem with a simple loop.

  • (cs)

    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.

  • JimM (unregistered) in reply to Maybe Anon
    Maybe Anon:
    JimM:
    Maybe Anon:
    OperatorBastardusInfernalis:
    [snip]

    But maybe there was a specific reason to do it in XSLT...

    No, no, no, no. Your doing it all wrong. Don't even THINK about how you could possibly justify this.

    Presumably someone did think of a justification for this, because it got written. So why shouldn't we try to think of one too?
    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.
    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? ;^)

  • eLAN (unregistered)

    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.

  • mister (unregistered) in reply to JimM

    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+

  • Edward Royce (unregistered) in reply to JimM
    JimM:
    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? ;^)
    <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.

  • Edward Royce (unregistered) in reply to eLAN
    eLAN:
    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.

    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?

  • Anonymous Coward (unregistered) in reply to tdittmar
    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?
    The real WTF is people referring to it as the "US" alphabet.
  • Alex (unregistered)

    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.

  • s. (unregistered) in reply to Edward Royce
    Edward Royce:
    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?

    The first instance of international system is usually english. Then you add other languages later on.

  • english speaker (unregistered) in reply to eLAN

    <Top Secret>English speakers don't care about other languages</Top Secret>

  • Shambo (unregistered) in reply to s.
    s.:
    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.

    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.

  • yer mom (unregistered)

    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?

  • Andrew (unregistered) in reply to eLAN

    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.

  • Polar (unregistered)

    Irish Day without Irish Girl...what has become of the world. :o(

  • (cs) in reply to Polar
    Polar:
    Irish Day without Irish Girl...what has become of the world. :o(
    Well, this year, St Pat's is actually on either 15th March or 1st April, depending upon who you believe. Have faith, little one.
  • 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.

  • (cs) in reply to T $
    T $:
    One word: Reusability.
    Five letters: YAGNI.
    disturbedHR:
    Fredrik:
    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...
    I agree, it's i18n ready. Enough said.
    How is this any more i18n ready than a Scrabble bag?
  • (cs)

    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.

  • HeXSL (unregistered)

    I had to refactor this recently... I think it was a case of "USE XSL, it's easy - you don't need to RTFM".

    	<xsl:template name="results">
    		<xsl:param name="N" />
    		<xsl:param name="upperLimit" />
    		<xsl:if test="$N &lt;= $upperLimit">
    			<xsl:if test="./ResultSet/Result[position()=$N]">
    				<xsl:element name="a">
    					<xsl:attribute name="href">
    						<xsl:value-of select="./ResultSet/Result[position()=$N]/URI"/>
    					</xsl:attribute>
    					<xsl:value-of select="./ResultSet/Result[position()=$N]/Title" />
    				</xsl:element>
    
    				<xsl:call-template name="results">
    					<xsl:with-param name="N" select="$N+1" />
    					<xsl:with-param name="upperLimit" select="$upperLimit" />
    				</xsl:call-template>
    			</xsl:if>
    		</xsl:if>
    	</xsl:template>
    

    That's only scratching the surface of what was wrong with the files.

  • Olson (unregistered)

    If you're going for code reusability and future proofing, why not just create a structure with any/all letters that are in use?

    <cfquery name="local.letters" datasource="#variables.dsn#">
    	SELECT DISTINCT
    		LEFT(LTRIM(surname),1) AS Letter
    	FROM [Staff]
    	WHERE [IsActive] = 1
    	ORDER BY LEFT(surname,1)
    </cfquery>
    
    <cfloop query="local.letters">
    	 #local.letters['Letter'][CurrentRow]# 
    </cfloop>
    
  • Olson (unregistered) in reply to Olson
    	ORDER BY LEFT(LTRIM(surname),1) -- Correction
    
  • (cs) in reply to mfah
    mfah:
    I'd hate to see their implementation of "Hello world".
       <root>
                <node>H</node>
                <node>e</node>
                <node>l</node>
                <node>l</node>
                <node>o</node>
                <node> </node>
                <node>W</node>
                <node>o</node>
                <node>r</node>
                <node>l</node>
                <node>d</node>
       </root>
    
       ...
    
  • Mr (unregistered)

    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.

  • JimM (unregistered) in reply to Edward Royce
    Edward Royce:
    JimM:
    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? ;^)
    <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.
    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

  • (cs) in reply to Mr
    Mr:
    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.
    "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.)

  • s. (unregistered) in reply to Shambo
    Shambo:
    s.:
    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.

    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.

    Oh, I'm not saying his solution was wrong or worse. I'm just saying it's somehow far-fetched definition of 'easier'.

  • Shambo (unregistered) in reply to s.
    s.:
    Shambo:
    s.:
    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.

    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.

    Oh, I'm not saying his solution was wrong or worse. I'm just saying it's somehow far-fetched definition of 'easier'.

    Ahh, yes. Easier is not the word I would have used.

  • IV (unregistered)

    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

  • JimM (unregistered) in reply to IV
    IV:
    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.
    But "the daily double-plus-ungood" just doesn't have the same ring to it...

Leave a comment on “The Alphabet... The Hard Way”

Log In or post as a guest

Replying to comment #:

« Return to Article