• Pat (unregistered)

    I'm sure there's some song about this... take 'em apart...put em back together and whaddya get? Though, it could be useful if later they intend to check the filename / path for other purposes.

  • Belcat (unregistered)

    Ahh, cut and paste programming. I don't know what this stuff does, I just cut it from the newsgroup, and put it in...

  • Aaron (unregistered)

    see.... I wish they would have made VB a little bit harder to learn, to keep away the stupid people. Or at least make it not a viable language to use for production-level programming!

    frist

    captcha: darwin -- if ONLY!!!

  • (cs) in reply to Aaron
    Aaron:
    see.... I wish they would have made VB a little bit harder to learn, to keep away the stupid people. Or at least make it not a viable language to use for production-level programming!

    frist

    captcha: darwin -- if ONLY!!!

    Good developers write programs. Bad developers write nightmares. Stupid developers write in Visual Basic.

    Too bad Micro$oft didn't go ahead and axe VB during the .NET launch. Forcing everyone to use C# would have weeded out the stoopid ones.

  • Theo (unregistered)

    Sometimes I read this site and I think: WTF?!?? But this one made me chuckle. The write-up was quite good.

    Furthermore, I really love this kind of code. In an ideal world, it wouldn't do any harm, just take a couple of CPU msec, but of course in the one, true, real world, well. Anyway, when I see something like this, I always try to imagine the sequence of events and the environment that served to concoct such a fine example of superfluous code. Was there originally a need to have path and filename separated? Was this code developed before the first VB library? Had the programmer forgotten where the path and file name came from? Was he just doing it to show his performance in coded lines per week? Or was he just stoned while coding and thinking how this spaced out? Will we ever know? Tune in next week for more worse than failures...

  • W (unregistered) in reply to Aaron
    Aaron:
    not a viable language to use for production-level programming
    Yeah they did that already.
  • KG2V (unregistered)

    I've seen similar code running around - in fact, there is a code snippet almost identical in one of my legacy projects. Why? Because back in VB3, you din't have some of these nice constructs, and well, it just hasn't been cleaned up - I look at it, shudder, and say "it works" - fix what needs to be fixed

    One day, the section of code that is in that area will need to be fixed, and I'll put some unit tests around it, and fix it

    I look around, and some of the worst code I see is OLD 16bit VB code, that has been ported, and ported, and used - often being maintained by good coders which are trying to keep the big ball of mud working - refactoring as they get time

  • (cs)

    It saves you the trouble of importsing System.IO.

    I used to kick over my brother's sand castle and then we would rebuild it. It was kind of fun!

    The anti-VB.net fanboi's are sure to be out in force for this one. I've seen great code and painful code written in all languages. VB's only fault is making it easier for novices to start up. It's not the programmer's fault someone is stupid enough to pay them for their miscarriages.

  • This is nothing... really... (unregistered)

    I once debugged 1500 lines of code that literally did a whole lot of nothing. It was a pile of statements like these taking things apart, putting them together, comparing the strings against themselves, and at the end it returned the same variables that were passed in. The truly sad part was this was code inside a custom built printer driver for a big name software contracting company. Their printer routines were notorious for being slow... some of that slowness was from the O(n^2) compare and do nothing loops in that 1500 line block of dead code.

  • AndrewVos (unregistered) in reply to danixdefcon5
    danixdefcon5:
    Aaron:
    see.... I wish they would have made VB a little bit harder to learn, to keep away the stupid people. Or at least make it not a viable language to use for production-level programming!

    frist

    captcha: darwin -- if ONLY!!!

    Good developers write programs. Bad developers write nightmares. Stupid developers write in Visual Basic.

    Too bad Micro$oft didn't go ahead and axe VB during the .NET launch. Forcing everyone to use C# would have weeded out the stoopid ones.

    This sort of ignorance is really starting to get to me.

    I have a MSN contact that wants to create a mmorpg. He is planning on creating his own programming language that interprets to ASM, and then he's then going to make an entire mmorpg in this new language. Why, you ask? "Because all modern languages are to slow!"

    Perhaps I should mention numerous friends of mine who are forced to use some redundant, ugly looking and old language because their boss heard that it's better.

    It's people like you that actually help in making the people around you stupider!

  • (cs)

    I love DIY file and path handling code. It's always ends up poorly. I had a friend who was writing a small web server in Java and wrote a class to ensure that the requested document wasn't below the root directory. He wrote it as a stack, kinda like this (in psuedocode):

    path = webRoot + request.queryString
    path = path.substring(0,path.findFirst ('?'))
    pathQueue = new Queue
    for i in path.split('/')
      if (i == "..")
        pathQueue.pop ()
      else if (i == ".")
        continue
      else
        pathQueue.push(i)
    end
    path = ""
    while i = pathQueue.pop()
      path = path + '/' + i
    end
    if path.startsWith (webRoot)
      openFile path
    

    Naturally, as soon as he tested it he found that he was permitting access to the whole system because he didn't forsee symlinks. There were a host of other errors as well, but I can't remember them off the top of my head.

  • Wizou (unregistered)
    pathFile = filePath.ToString()

    very useful...

  • Gijs (unregistered)

    My favourite part is the

    pathFile = filePath.ToString()

    This programmer managed to put as many as three WTF's in one line:

    • The pointless usage of the String.ToString() function
    • The usage of two completely similar and easily confusable variable names
    • And last but not least, the whole renaming is just a complete waste of CPU cycles
  • Michael (unregistered) in reply to AndrewVos
    AndrewVos:
    This sort of ignorance is really starting to get to me.

    I have a MSN contact that wants to create a mmorpg. He is planning on creating his own programming language that interprets to ASM, and then he's then going to make an entire mmorpg in this new language.

    You mean C?

    Why, you ask? "Because all modern languages are to slow!"
    Right, let us know how this turns out.
    It's people like you that actually help in making the people around you stupider!
    Don't blame others for your own problems, I'm betting you got stupid all on your own.
  • moonbiter (unregistered)

    I am not a programmer, just a web designer who putters around with JavaScript. Still, this one made me laugh out loud.

  • (cs) in reply to Gijs
    Gijs:
    My favourite part is the
    pathFile = filePath.ToString()
    This programmer managed to put as many as three WTF's in one line: - The pointless usage of the String.ToString() function - The usage of two completely similar and easily confusable variable names - And last but not least, the whole renaming is just a complete waste of CPU cycles
    Are Strings in VB immutable? Because if so, the whole thing is doubly stupid.
  • (cs) in reply to Pat

    This kind of reminds me of a compiler optimization performance comparison test (done by PC Magazine) from a long time ago; some nested loop construct written in both Turbo Pascal and C. The TP version kept finishing in 0 ms. Upon investigation, they realized that the compiler had optimized the entire nested loop construct into something like x=1, which of course, finished instantly.

    Maybe we could invent something that would optimize away wtf-developers... What do ya say gang?

  • iNeedAVacation (unregistered)

    I didn't get much from the artcile, but I really want to go to The Bahamas now.

  • (cs) in reply to bstorer
    bstorer:
    Gijs:
    My favourite part is the
    pathFile = filePath.ToString()
    This programmer managed to put as many as three WTF's in one line: - The pointless usage of the String.ToString() function - The usage of two completely similar and easily confusable variable names - And last but not least, the whole renaming is just a complete waste of CPU cycles
    Are Strings in VB immutable? Because if so, the whole thing is doubly stupid.
    Philosophical question: can you ever really waste cpu cycles that have already been bought and paid for? I have a box sitting here that does who-knows-how-many millions of nop's every second. And the company won't let me donate them to research *sighs*
  • Anita Tinkle (unregistered)

    This code example is not surprising. It is a VB5/VB6 developer who is used to that environment trying to cope in a .NET world. I wouldn't be surprised if the original author was a peeved in-duh-vidual in the office; stemming from the entire world passing him/her by in a matter of the four years it took the industry to switch to .NET

    Code blocks like that one are primarily why most shops will leave VB6 and go to C#.NET and NOT make the transition to VB.NET since most people making the transition not only have to suffer the indignation of learning a Java-syntactically equivalent language, but then also have to learn more about what an object framework is and actually use one. The result is usually more maintainable code.

    That, and Visual Basic is such a pain on the hands to write--I get carpal tunnel after writing it for a few hours. It's a PITA.

    CAPTCHA: muhahaha

  • Joseph Newton (unregistered) in reply to danixdefcon5
    danixdefcon5:
    Aaron:
    see.... I wish they would have made VB a little bit harder to learn, to keep away the stupid people. Or at least make it not a viable language to use for production-level programming!

    frist

    captcha: darwin -- if ONLY!!!

    Good developers write programs. Bad developers write nightmares. Stupid developers write in Visual Basic.

    Too bad Micro$oft didn't go ahead and axe VB during the .NET launch. Forcing everyone to use C# would have weeded out the stoopid ones.

    I don't mean to pick on you in particular, since there's a lot of this going around, but this is really silly. Get it straight:

    C# != C C == VB + C-style syntax

    I'll admit, I have not made much use of C#, but all it really takes is to look through the documentation for VS.Net.

    The sample programs all basically have parallel examples for VB and C#. The only discernable difference is in the syntax. The logic is exactly the same.

    So which end of the egg do we crack?

  • (cs) in reply to snoofle
    snoofle:
    Philosophical question: can you ever really waste cpu cycles that have already been bought and paid for? I have a box sitting here that does who-knows-how-many millions of nop's every second. And the company won't let me donate them to research *sighs*

    Sure you can. You can not use them for something. If you don't use them for anything at all, they've gone down the crapper. Hmm.... maybe finding a way within GAAP to call it a charitable deduction for partial use of the system would get a PHB's attention?

  • (cs) in reply to danixdefcon5
    danixdefcon5:
    Good developers write programs. Bad developers write nightmares. Stupid developers write in Visual Basic.

    Are you just trying to sound cool, or do you really believe that?

    I started with GWBASIC in DOS and went to QBASIC, VB3, then VB6. Some of my VB6 apps do mission critical work. My supervisor has already told me many times that my work is rock-solid and garners no complaints from the clients. The same cannot be said for the other developers (who use other languages).

    I also work with a multitude of databases and know other languages (JavaScript and C# among them). I use whatever will fulfill the need at the time (including the insane deadline promises that sales keeps making to the clients)

    So just because I do most of my development in VB6 makes me stupid?

  • MrJohnson (unregistered)

    I believe he used pathFile and fileName for something and later deleted that part of code and forgot to clean up this part.

  • Dr. Advil (unregistered)

    Maybe he just wanted to show all the other lowly developers how good at regular expressions he was. Not many can comprehend a regex as complicated as ""!!!

  • (cs) in reply to snoofle
    snoofle:
    This kind of reminds me of a compiler optimization performance comparison test (done by PC Magazine) from a long time ago; some nested loop construct written in both Turbo Pascal and C. The TP version kept finishing in 0 ms. Upon investigation, they realized that the compiler had optimized the entire nested loop construct into something like x=1, which of course, finished instantly.
    I had the opposite problem a few years ago, MSVC++ 2003 was optimising the million iteration loop to a single assignment, and disabling optimisations made other languages seem faster (redundant memory reads and assignments instead of using registers etc). Using a different c++ compiler that wasn't as good at optimising sorted it and showed that C++ really was the superior language.
  • Rich (unregistered) in reply to AbbydonKrafts
    AbbydonKrafts:
    So just because I do most of my development in VB6 makes me stupid?

    You appear to have hit the question mark by accident at the end of that sentence.

    I certainly know that when I delved into VB once, I felt the IQ points slipping away...

    Rich

  • Asd (unregistered) in reply to Joseph Newton
    Joseph Newton:
    C# != C C == VB + C-style syntax
    C# == Java with syntactic sugar (or maybe Java.equals(C#)) C# 1.0 of course, it is diverging rapidly.

    Nice write up for this WTF. I thought it was going to be a really weak one, and then BOOM.

  • (cs) in reply to Rich
    Rich:
    AbbydonKrafts:
    So just because I do most of my development in VB6 makes me stupid?

    You appear to have hit the question mark by accident at the end of that sentence.

    I certainly know that when I delved into VB once, I felt the IQ points slipping away...

    Rich

    To bad it was because you were incapable of thinking beyond your current evolution rather then the exposure to VB itself.

    Seriously, VB is simply a language. Both good code and bad code can be written in it. I will agree that most beginners start with VB and don't learn proper coding techniques or even some basic theory, but that is not a problem with the language.

  • (cs) in reply to Rich
    Rich:
    AbbydonKrafts:
    So just because I do most of my development in VB6 makes me stupid?

    You appear to have hit the question mark by accident at the end of that sentence.

    I certainly know that when I delved into VB once, I felt the IQ points slipping away...

    Rich

    I agree. Whenever I have to do anything with VB, I feel like I'm programming in Retard, simply because of the byzantine and non-sensical methods of doing things. = for evaluation AND assignment? Argh!

  • Matt S (unregistered) in reply to danixdefcon5

    Just had a project taking about 50 spreadsheets and consolidating them into about 3 while leaving lots of data driven stuff easily available to the users. I wrote some VBA macros. Why in the world would I have written a C# program instead?

  • Pon (unregistered) in reply to KattMan
    KattMan:
    Rich:
    AbbydonKrafts:
    So just because I do most of my development in VB6 makes me stupid?

    You appear to have hit the question mark by accident at the end of that sentence.

    I certainly know that when I delved into VB once, I felt the IQ points slipping away...

    Rich

    To bad it was because you were incapable of thinking beyond your current evolution rather then the exposure to VB itself.

    Seriously, VB is simply a language. Both good code and bad code can be written in it. I will agree that most beginners start with VB and don't learn proper coding techniques or even some basic theory, but that is not a problem with the language.

    In my opinion, it's a problem with the design and philosophy of the language; so it's very close.

  • (cs)

    The real WTF (ugh) is that we're complaining about different programming languages, which are essentially the same with varying amounts and types of syntactic sugar, when really we should be complaining about all the quirks and WTFs of the human languages we speak :)

  • Niall (unregistered) in reply to danixdefcon5

    Too bad Micro$oft didn't go ahead and axe VB during the .NET launch. Forcing everyone to use C# would have weeded out the stoopid ones.

    Hmm, that strategy hasn't worked with Java in general and J2EE in particular.

  • Niall (unregistered) in reply to Thief^
    Using a different c++ compiler that wasn't as good at optimising sorted it and showed that C++ really was the superior language.

    that comes across as, I know the result I want and I'll keep going till I get it, relatively harmless in programming, absolutely disastrous in war and somewhere in between in romantic relationships.

    I'll go with choose you language appropriately, and your tools for that language carefully.

  • Eff Five (unregistered) in reply to danixdefcon5

    I totally agree. There’s no way a C-Pound dev would have written something like :

    string fileName; fileName = myDialog1.FileName; string[] filePaths = fileName.Split("\".ToCharArray()); string filePath; int i; for (int i = 0; i < filePaths.Length -2; i++) { filePath.Append(FilePaths(i)); filePath.Append("\");

    } pathfile = filePath.ToString(); fileName = filePaths(filePath.Length - 1).ToString();

  • (cs) in reply to Volmarias
    Volmarias:
    Rich:
    AbbydonKrafts:
    So just because I do most of my development in VB6 makes me stupid?

    You appear to have hit the question mark by accident at the end of that sentence.

    I certainly know that when I delved into VB once, I felt the IQ points slipping away...

    Rich

    I agree. Whenever I have to do anything with VB, I feel like I'm programming in Retard, simply because of the byzantine and non-sensical methods of doing things. = for evaluation AND assignment? Argh!

    English: "Make 'x' equal to '4'." VB: x=4

    English: "Does 'x' equal '4'?" VB: If x=4

    Not seeing the problem here. Using two '=' signs for comparison? "Does 'x' equal equal '4'?" Yeah, that just clicks for me...

  • uhe (unregistered) in reply to AndrewVos
    I have a MSN contact that wants to create a mmorpg. He is planning on creating his own programming language that interprets to ASM,

    'interpret to ASM'? That sounds like an interesting concept... yes I know he probably means to compile to ASM, JIT-like but with people that are so 'advanced' you never know.

    Is creating your own language like writing your own scene graph? Like you have to do it at least once to qualify as a Real Programmer?

  • (cs) in reply to snoofle
    snoofle:
    Philosophical question: can you ever really waste cpu cycles that have already been bought and paid for? I have a box sitting here that does who-knows-how-many millions of nop's every second. And the company won't let me donate them to research *sighs*

    They are doing HALTs not NOPs. And just a few per second :)

  • (cs) in reply to tmountjr
    tmountjr:
    English: "Make 'x' equal to '4'." VB: x=4

    English: "Does 'x' equal '4'?" VB: If x=4

    Not seeing the problem here. Using two '=' signs for comparison? "Does 'x' equal equal '4'?" Yeah, that just clicks for me...

    BASIC born 1963. Utilises the "Let" keyword so it's bleedin' obvious that "Let x = 1" is an assignment. Let later dropped because it was bleedin' obvious by way of context of statement what was going on to anyone that speaks English. C born 1972. Thinks all this statement context is a load of hooey and introduces new comparator. JavaScript born around 1995 (originally called LiveScript). Thinks that == just isn't enough in some instances and gets around having to do separate object equivalence checks with a new comparator of ===. Used when you REALLY need to ensure something is null or 0 (see Doug Crockford) or some object constructor is completely utterly and irrefutably Array...

    And this is called "progress"?

  • mullzk (unregistered)

    just laughed out very loud in my café - everyone staring at me. what a great SOD....

  • Greg (unregistered) in reply to danixdefcon5
    danixdefcon5:
    Aaron:
    see.... I wish they would have made VB a little bit harder to learn, to keep away the stupid people. Or at least make it not a viable language to use for production-level programming!

    Good developers write programs. Bad developers write nightmares. Stupid developers write in Visual Basic.

    Too bad Micro$oft didn't go ahead and axe VB during the .NET launch. Forcing everyone to use C# would have weeded out the stoopid ones.

    No then what you would have had is all the "stoopid ones" writing what they think is C# instead. And you would have been spending your time fixing all of their CodeSOD's because you know the language.

    The real "stoopid ones" are the people who think a programming language makes them superior.

  • Zaphod Beeblebrox (unregistered)

    I think the filePath variable is supposed to be a StringBuilder, as Append isn't a function of String. That would also explain the ToString() at the end. Not that I really want to defend the code or anything.... Just think something got lost in translation there.

  • Markus (unregistered)

    I agree that there are many mistakes in this code snipet. But in general it seems that many WTFs here could very well be introduced by automatic conversion from, say, VB6 to VB.NET or C#. Infact, I have two projects which have automatically been converted from VB6 to VB.NET and then to C#. They are full of expressions like

    int fDouble = System.Convert.ToInt(System.Convert.ToDouble(strString.ToString().Left(3).ToString())));

    which were introduced by the automatic conversions.

  • Superlexx (unregistered)

    I usually write code in C-style-syntax languages, but once in a while it's a VB-language. My conclusion is:

    In a C-styled language, you know that when it looks messy, you're doung something wrong (time for a tea and some refactoring). In VB, it looks messy almost instantly, so you just don't care about quality that much.

  • VBGuy (unregistered) in reply to danixdefcon5

    Programmers are either good or bad, it doesn't matter what language they write in, if they suck, they suck in any language.

    If you think taking away VB would take away bad programmers, you are way to naive my friend.

  • (cs) in reply to Michael
    Michael:
    AndrewVos:
    This sort of ignorance is really starting to get to me.

    I have a MSN contact that wants to create a mmorpg. He is planning on creating his own programming language that interprets to ASM, and then he's then going to make an entire mmorpg in this new language.

    You mean C?

    Why, you ask? "Because all modern languages are to slow!"
    Right, let us know how this turns out.

    He could write it as a MUD. That would work AND be super fast.

    Yeah, it'll be featured here eventually.

  • Steve (unregistered) in reply to This is nothing... really...
    This is nothing... really...:
    I once debugged 1500 lines of code that literally did a whole lot of nothing. It was a pile of statements like these taking things apart, putting them together, comparing the strings against themselves, and at the end it returned the same variables that were passed in. The truly sad part was this was code inside a custom built printer driver for a big name software contracting company. Their printer routines were notorious for being slow... some of that slowness was from the O(n^2) compare and do nothing loops in that 1500 line block of dead code.

    Could this have been set up to sell an "Enhanced" printer driver once the customer saw how slow the sabotaged one was? Hardware manufacturers used to play that game, in the form of expensive speed upgrades that consisted of a tech moving a clock-speed jumper and replacing one deliberately underspecified chip that would go flakey if the customer moved that jumper himself.

  • (cs) in reply to AbbydonKrafts
    AbbydonKrafts:

    I also work with a multitude of databases and know other languages (JavaScript and C# among them). I use whatever will fulfill the need at the time (including the insane deadline promises that sales keeps making to the clients)

    So just because I do most of my development in VB6 makes me stupid?

    Not at all. Your programming language doesn't mean a thing in terms of your programming ability. Some people say it's a tool. You don't see carpenters talking about whether a hammer is a better tool than a saw. (I think it's more like choosing a wood, but that's just going to lead to comments about balsa wood or MDF.)

    I program mostly in C for embedded systems. I've used VB6 and VB.NET to make interfaces for the devices. VB6 is easier to use, since it's got native COM port use.

    If someone's bashing VB for no reason, it's probably because they're insecure about their abilities at their jobs, and they know that there are enough people to agree with their VB bashing that they can glean some sort of fulfillment in their lives.

    If they were saying something like, "The problem with VB is in the complier. Microsoft's QNR protocol leads to memory leakage when dealing with more than 500 simultaneous rashdanderings. The issue wasn't resolved until the VS.NET 2005 compiler build 513 - SEVEN YEARS after the initial release!" That's a legitimate concern. Even being wrong is okay: "VB doesn't have any error handling!" (despite OnError goto... )

    If the complaint are "eat a can of cold pork brains" and "goto is teh stupid" then it's just baseless vitriol. (Both of which are points brought against VB in the last week.)

    Every language has its idiots. I've seen some embedded C code that I can't share because you'd kill yourself and I don't want to be blamed for all those homicides.

  • (cs) in reply to Steve
    Steve:
    This is nothing... really...:
    Their printer routines were notorious for being slow... some of that slowness was from the O(n^2) compare and do nothing loops in that 1500 line block of dead code.

    Could this have been set up to sell an "Enhanced" printer driver once the customer saw how slow the sabotaged one was?

    Never attribute to malice what can be adequately explained by incompetence... or regulatory standards documents.

Leave a comment on “Putting It All Together”

Log In or post as a guest

Replying to comment #:

« Return to Article