• (cs)

    If he reduced the lines of code, of course he would get paid less! Should have jacked it up to 4MB! [A]

  • (cs)

    Oh, come on -- the guy COULD have looked up the values to an external reference, preferably over a slow WAN or even gotten a URL and parsed it out of a reference web page. There are MUCH worse ways of doing almost anything[8-|]

  • (unregistered)
    And, naturally, Jørn was paid a fair 200-400% less than the original consultants who developed it.

    Wait, so he paid them one to three times the cost of original development?

    That is a major WTF.

  • (unregistered)

    Not to be too picky here... but how can you get paid 400% less than the original implementers? Did the poor lad have to shell out three times as much to the company as the company originally paid? That seems harsh, even in the current economic conditions.

    Oh, the code? Horrible How on earth does someone commit something that brainless?

    R

  • (cs) in reply to

    Picky, Picky Picky! [;)]

    Actually, he said that the consultants were paid 400% more ... but i guess it doesn't work so well the other way around. Although, it sure as hell does sound like less than "75-80% less"

  • (unregistered)

    I'm not sure if I want to see the URLDecode-function


    Cheers, Lothar

  • (cs)

    Absolutely frightening.[:S]

  • (unregistered)

    Well at least he didn't attempt to encode the Unicode character set, 65k select conditions anyone???

  • (cs) in reply to
    :
    I'm not sure if I want to see the URLDecode-function
    Most probably they didn't know about the Server intrinsic object completely. Which case I'd like to see how they implement MapPath() [:P]
  • (unregistered)

    This kind of code pisses me of along with the fact that the consultant was paid much more than the guy who fixed it. Shit.

  • (cs)

    C'mon Guayo, I know you want to defend this code by saying that someday the conversion process from Base-10 to Hex might change and that hardcoding was not necessarily a bad idea.

  • (cs)

    The thing is, it should matter if you have no clue that a method exists to do this or not.  If you are programming computers, you really need to understand the basics.   Stuff like this drives me nuts.  If you can't throw together a quick function that converts a character to a hexidecimal string, you really have no business writing programs at all.  Even a language like QBasic provides all the tools you need to do this in a couple of lines.


  • (cs)

    Oh and I like how he has a "Case Else" in there, because I heard the plans are moving ahead to expand the ASCII table beyond 256 characters. And for those who want to start talking about Unicode, I've had a little experience with this. If you use Chr() on a Unicode character, it always evaluates to "?" (ASCII Int 63/Hex 3F). This WTF just makes my pancreas bleed.

  • (cs)

    This example demonstrates why I think C++ is such a great language. If the programmer who wrote this had tried to write the application in C++, he would never have completed the task and nobody would have had to go back and fix it.

    They could start from scratch, a much easier and rewarding task.

    We need to start making our computer languages HARDER to use.

  • (unregistered) in reply to Rick

    Check out Case 32:

       Case Chr(32) 
        Buffer = Buffer & "+"

  • (unregistered)

    Heh.. this reminds me of some code on an auction site I had to edit recently.

    The code consists of nonsense such as


    Replace(Replace(Replace(Replace(Replace(Trim(sTitleAr(pintCount)), "&", "%26"), " ", "%20"), "'", "%27"), "`", "%60"),"-","%2D")


    Hand coded categories:


    Dim sCSel() ' don't alter this line of code
    ReDim sCSel(pCatTot - 1) ' don't alter this line of code

    sCSel(0) = "Antiques & Collectibles"
    sCSel(1) = "Art & Galleries"
    sCSel(2) = "Benefits & Charity"
    sCSel(3) = "Business Liquidations"
    sCSel(4) = "Carnivals & Amusement Parks"
    sCSel(5) = "Collector/Vintage Cars & Equipment"
    sCSel(6) = "Computers & Electronics"
    sCSel(7) = "Estate & Personal Property"
    sCSel(8) = "Farm & Ranch"
    sCSel(9) = "Government & Municipal"
    sCSel(10) = "Heavy Equipment"
    sCSel(11) = "Industrial & Manufacturing"
    sCSel(12) = "Laboratory & Pharmaceutical"
    sCSel(13) = "Logging & Forestry"
    sCSel(14) = "Media"
    sCSel(15) = "Miscellaneous"
    sCSel(16) = "Office & Business Equipment"
    sCSel(17) = "Real Estate - Commercial"
    sCSel(18) = "Real Estate - Land"
    sCSel(19) = "Real Estate - Residential"
    sCSel(20) = "Restaurant & Food Industry"
    sCSel(21) = "Automobiles/Transportation"
    sCSel(22) = "Trucks & Trailers"
    sCSel(23) = "Intellectual Property"


    And too much more. There's a large switch statement somewhere in it that is quite amusing, sadly I cannot locate it (give me a break... it's 80K lines of code scattered throughout 200 files) :)

  • (unregistered) in reply to Manni

    Not that I'm defending the monstrosity but the "else" clause does get executed for URL friendly characters such as a-z,A-Z,0-9.  You'll notice that 65-90 are missing from the case statement so that they get picked up by the else.  See, it could have been worse... the coder could have done a case for the normal characters too... [+o(]

  • (unregistered)

    [:|] Wow...  Just amazing...  I'm speachless.

  • (unregistered) in reply to
    :
    Check out Case 32:
      Case Chr(32) 
        Buffer = Buffer & "+"

    Huh? ASCII 32 is a space, and it can be encoded as a +, or %20, both work fine.
  • (unregistered)

    I hope this is not VB.NET (len(somthing) vs something.length and using Mid to get a character? use string[index], please.)

    Also note how he does Buffer = Buffer & ""... And that he implements all 255 possible values and still makes a default. It would actually be relevant if it wasn't for the fact he would be using unicode strings, but as far as I can see here he's not doing anything like that at all. This is just wtf.

  • (unregistered)

    I guess this is a good example of a situation in which open source is an advantage. Of course errors can still remain undetected, but the chances are way smaller that anybody would get away with something like this.

  • (cs)

    This is EXACTLY why pure VB 'programmers' should be put in their own world and left to do their own thing which doesn't affect anybody else.
    I suspect the 'programmer' doesn't even know what hexadecimal is.

    I 'program' in VB every day, but I also do Java, C, C#, Transact-SQL and at least have some idea of programming theory. People who only do VB should be SHOT because the rest of us have to spend our time picking their code to pieces and making it work efficiently.

    Things I wonder about pure VB 'programmers':

    Do they know what ASCII is?
    Do they know that if you hold down ALT and type in an ASCII code on the number keypad, that character is displayed?
    Do they know binary?
    Do they even have the smallest clue about OO ?

    ok, weird list, I know, and I could go on and on and on, but I can't be bothered. I know none of those things are particularly important by themselves (except perhaps the OO one), but they all help programmers along in their merry way, and come in handy all the time. They are examples of things picked up with years of experience, not things you learn in 2 days on a crappy VB course.

    Unfortunately, VB is giving programmers a bad name. It's now WAY too easy for somebody to learn to 'program' and bodge something together in very, VERY bad ways.

    Right. Rant over.

  • (unregistered) in reply to

    You can laugh, but back in the early '80s I worked on a project that had a 32,000+line switch statement.  Actually, nested switch statements.  So many that lines started in column 75.  Just imagine being a thousand lines into it and seeing a break statement.   To top it off, the non Unix C compilers weren't very good back then so you really had no idea where it was going.

  • (unregistered) in reply to DJDanny

    Wow. I didn't know that thing about holding down Alt and typing a number on the number pad! You can really learn something new every day! Thanks. BTW, I am familiar with all the other stuff on your list.[:D]

  • (cs)

    For .Net programmers the better link would be this one.  But notice it is still in System.Web, so if you are not developing an ASP page you must link a 1.2 Meg assembly just to be able to use a simple static encoding function.  And that is if you, a non web-developer, even think to look for it there. (why the heck doesn't System.UriBuilder have this?).  In VB6 I'm not sure there even is a built in function (maybe some win32 api function I've forgotten?).

    Sure this code is fugly, but unless this is ASP code, don't be so quick to call it a RE-implementation.

  • (cs) in reply to
    anonymous:
    in the early '80s I worked on a project that had a 32,000+line switch statement.  Actually, nested switch statements.

    [:D] Wow.  That project wouldn't happen to be the source of the famous AT&T "break;" bug, would it?

    (sorry for the double post)
  • (cs) in reply to DJDanny

    DJDanny,

    <font size="2">>> I 'program' in VB every day, but I also do Java, C, C#, Transact-SQL and at least have some idea of programming theory. People who only do VB should be SHOT because the rest of us have to spend our time picking their code to pieces and making it work efficiently.

    I better go shoot myself then.

    Good to see another pointless rant that extrapolates from one WTF programmer to all 'VB only' programmers.

    I assume you are a member of some active VB lists? If not, come on over, and we'll teach you a thing or two.

    http://peach.ease.lsoft.com/archives/visbas-l.html
    http://discuss.develop.com/vbdotnet.html

    Matthew</font>

  • (unregistered) in reply to RJ
    Sure this code is fugly, but unless this is ASP code, don't be so quick to call it a RE-implementation.

    But there's still the built-in Hex() function. No need to state each case explicitly.

    Of course, you could go overboard with that too; I've seen URLs with all the letters and numbers encoded!
  • (cs) in reply to

    Hex() is an improvement, though you still need extra work to get the leading zero and iterating characters in a VB6 string is never fun.

    Today's wtf just gets under my skin because the lack of a centrally located microsoft supplied URLEncode function has been a pet-peeve of mine for the last 6 years.

  • (cs)

    That made my head hurt. If you scroll up and down really fast, it makes you dizzy and light-headed.

  • (unregistered)

    "VB is giving programmers a bad name."

    No, I disagree...  Programmers are making Managers(or any business person) look stupid...  For a good reason, they are stupid.

    Reason 1:
    Some company wants some program like the other company has...  so a consultant (not necessarily a programmer) kisses their ass and they pay him $X million dollars for it.  Even though they could have had it done it better/faster/cheaper, they do it anyway cause this consultant bought them dinner and a lap dance.

    Reason 2:
    The problem is closed source.  Would you buy a used car from a mechanic that welded the hood shut and expected you to call only him if it ever stoped working?


    Whos the bigger idiot?  The programmer who cant code? or the company that hires him?(or buys his product)

  • (cs) in reply to

    Folks, there's no such thing as a bad programming language. (Even Logo had a crapload of powerful possibilities if you forgot about the turtle for a few seconds.) There are, however, bad programmers, and their weapon of choice makes little difference. C/C++ guys loop around their memory releases more often than not, C# folks don't have the whole Framework memorized and reinvent the wheel as much as anyone else, and I can tell I'm in for a rough ride when I see "theObjectName" used as a variable in Java. (I'm sure their are APL WTFs as well, but I can't tell offhand whether the flagstick should have been stuck through an upright or an inverted triangle.)  Point is, it ain't the hammer that's bad, it's the carpenter.

    What makes VB a special case is that just about anyone can write something that works. Well, sort of, at least, and it's those accidental developers who go on to create the universe as we know it. By the same token, there are a lot of people on the platform who could code circles around "certified professionals" who have only proven the ability to read a book and pass a test.

    No getting uppity -- your pet language is no better than anyone else's. Not Java, not C, not assembler. Not even if you code in nothing but ones and zeroes. And if you're down at the iron, no-one will ever find the evidence of your mistakes in the smoking rubble you leave behind. Your WTF becomes a WTF happened?

  • (unregistered) in reply to

    VB ain't so bad... it's a good way to make some quick cash.

    Steve.

  • (cs)

    I stand corrected, and I freely admit I made a mistake when I mocked the programmer's inclusion of the "Case Else". He was intelligent enough to realize you don't have to convert the letters of the alphabet. I overlooked it because the toolbag actually wrote out the other 200+ cases, and I just lost count.

    And I concur with the other rants against VB programmers. People that have no business compiling anything are writing their little Excel macros and "Hello World" applications, suddenly they're asked to do something a bit more complex and this is the crap that comes out. I am a VB programmer so I know how easy it is to write it, but I'm nowhere near this bad.

  • (cs)

    WTF!!!
    This line is not properly indented!

    Buffer = Buffer & "%0E"

  • (cs) in reply to Manni

    Manni:
    C'mon Guayo, I know you want to defend this code by saying that someday the conversion process from Base-10 to Hex might change and that hardcoding was not necessarily a bad idea.


    Ok, the guy didn't hear of the Hex function, If this is ASP he didn't hear of Server.URLEncode function.
    But hey! The code works... For a TDD standpoint this code is better than one using built in functions that fails.
     I'm not saying it isn't poorly done, of course it is. But a WTF2? [:^)]

    I+think+the+real+WTF+here+is+the+little+%24+J%F8rn+Aakre+got. [;)]

  • (unregistered) in reply to Guayo

    Yes, this is a WTF.

    Again, even if you don't know that a function or method exists to do this, even if the language you are programming in doesn't have a HEX$ function, regardless of  the tools you have, if your programming language can convert a character to an ASCII value, and it lets you do some math, then you never have an excuse to write crap like this.

    Again, to me, if there's an existing function in a library that handles this and it's missed, but the programmer implements some code for it correctly, quickly and elegantly, to me that's not a bad thing at all.  Often, that library may not have even existed when the code was first written anyway.   Anyone can memorize a library -- very few people can write code when they don't have things pre-written for them.

    Being a programmer isn't about memorizing libraries or being quick to google (though that definitely helps, don't get me wrong) to find some sample code you can cut and paste, it's knowing how to solve problems and write alogorithms. Most importantly, it's knowing how to do conversions and how to use simple mathematics to get the job done. 

  • (cs)

    (sorry, that last post was from me, i wasn't logged in [:$])

  • (unregistered)

    This looks like it was written by a DIY VB Programmer... particularly at the start of the .com boom, a programmer could write something simple that looked complicated in VB, mostly by clicking buttons.. they didn't have to know much (as this fellow proves).
    Companies would take them on because they couldn't find anyone else or didn't know what to look for (remember that most of todays managers got their start back then), and the "good programmer" standards were, umm... chucked out the window or missed all together.

    I suspect there is a good chance this fellow is not working in software now... can I take your order please?

  • (unregistered)

    Alex,

    You know already that I'm a big fan, as I've contributed a couple of times.  But again, THANK YOU so much for this site.  I don't feel alone, and I feel grateful for my job where there are some good programmers (as opposed to my last job, which contributed to two or three posts on this site.)

    And thanks to the guy who mentioned the 32k line switch/case statement.  i'm of the opinion that switch/case is almost never necessary, so it makes me feel good that in my short career (6+ years) I haven't seen one that long.  Maybe we as an industry are making some progress.

    And yes, pure VB programmers suck.  My last job confirmed that (www.True.com.)  I started with VB and Coldfusion, and turned to Java and C#.  I feel better now.

    -Craig

  • (unregistered) in reply to
    :
    i'm of the opinion that switch/case is almost never necessary, so it makes me feel good that in my short career (6+ years) I haven't seen one that long.
    Switch/case is a remnant of the traditional structured programming languages, which was (is) a slight improvement over the even-older technique of multiple if-else cases.

    I however reckon it true with the OO approach you should be able refactor most of these out with "Replace Condition with Polymorphism".
  • (cs) in reply to

    Wow... now it's my turn to have my cookie mysterious expire and have to post annoymously above.

  • (unregistered)

    It's not that obvious, but all of the ASCII set isn't implemented.
    48-57, 65-90 97-122 (Ie. digits, lower case and upper case) are all missing.

     It's still terrible, but there is a reason for the else statement.

  • (unregistered)

    Maybe the programmer should be mentioned on the http://www.darwinawards.com/ site. These kind of people really need to quickly exit our gene pool, man.

  • (unregistered)

    <font style="BACKGROUND-COLOR: #efefef">The given code really isn't a reimplementation.

    As far as I can tell from the cited MSDN page
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/ref_vbom_seromuenc.asp
    the Server.URLEncodefunction operates on the actual characters of the string.  I haven't tested it, but it sure looks that way.

    The given code operates on the bytes of the string.  The given code doesn't care whether the string is ASCII or not.  If the string is Unicode or if just about any code page other than US is in use, the given code surely produces different results from what Server.URLEncode produces.
    </font>

  • (unregistered) in reply to
    :
    [image]  wrote:
    Check out Case 32:
      Case Chr(32) 
        Buffer = Buffer & "+"

    Huh? ASCII 32 is a space, and it can be encoded as a +, or %20, both work fine.
  • (cs) in reply to Stan Rogers
    Stan Rogers:
    Folks, there's no such thing as a bad programming language.


    Indeed, this I agree with. However, there are languages in existance which do nothing to encourage you to program in a decent way - they let you get away with too much rubbish, and this is the problem with VB.
  • (cs) in reply to mjwills

    mjwills:
    DJDanny,
    <font size="2">
    I assume you are a member of some active VB lists? If not, come on over, and we'll teach you a thing or two.

    http://peach.ease.lsoft.com/archives/visbas-l.html
    http://discuss.develop.com/vbdotnet.html

    Matthew</font>


    Well, I took the time to have a look through the list archives, and the majority of the questions are very very basic, and show how the VB world is polluted with people who would otherwise not be able to program.

    Here's an example question I picked out at random:

    <font face="Courier New">My problem is when I am downloading [an HTML page] using
    Webclient.DownloadFile I am not getting the images
    that might exist on the web page.
    </font>
    (taken from http://discuss.develop.com/archives/wa.exe?A2=ind0409d&L=vbdotnet&T=0&F=&S=&P=174)

    This guy clearly doesn't even know how HTML or HTTP works! he thinks the images are somehow embedded within the document!

    This has to be a WTF in itself!

    Sorry, but you've merely confirmed what I already thought about pure VB 'programmers'.

  • (cs)

    [:|] Well we have a winner. I don't think I have ever seen or will ever see anything quite that bad.

  • (cs) in reply to RJ

    One URLEncode() function - or at least, a simple one with a single parameter - isn't enough. Different characters must be escaped, depending on which part of the URL they're going into. The query part has the special rule that space can be encoded as "+" and "+" must be encoded as "%2B". In the path part this would be wrong. Now it's possible to play safe by encoding space as "%20" and "+" as "%2B" but this might be undesirable. The path part uses "/" as a hierarchical separator, but on some OSs it's possible to have "/" in a path component, in which case it would have to be escaped in the URL. So the treatment of "/" depends on whether it's going into a path component or a complete path.

Leave a comment on “Worst. Reimplementation. Ever.”

Log In or post as a guest

Replying to comment #:

« Return to Article