Was this code hand-copied?



  • I can think of no better explanation than the subject line above.  Earlier today, whilst following the directions of some random, helpful programmer, I opened this microsoft kb article (http://support.microsoft.com/kb/147659) with VB code. I was actually surprised at so many obvious errors in a kb article. This thing won't even compile until you fix them.

    (I'd say "see if you can spot the WTFs", but you won't bother. that's fine. I highlighted them for you)

    Considering the purpose of kb articles is to TEACH something to young & budding code artisans, wouldn't it make sense for the code to be correct?

     




  •  Why are you looking at KB articles for VB 5.0?



  • TRWTF is that they have C style macros in VB. Until today, I was blissfully ignorant of this WTFery. So that's TRWTF, and the use of static integers inside a function to count recursion level. And the fact the code can run in Win16. I guess the typos happened because the code was old and the original punch cards were no longer readable by a supported device, so they indeed had to type the whole thing.

    Anyway, it's annoying that MSKB code contains errors indeed.



  •  To be fair, if you have a need to count recursion levels, static variables are the way to do it.



  • @Joeyg said:

    Filed under: I have a need. The need for SPEED.

    You sure it's not the need for clean underwear?



  •  VB pre-.NET is made of WTF.  I mean, honestly, some of that crap makes the other language I use at work (MUMPS) seem sane by comparison. 



  • @Joeyg said:

     To be fair, if you have a need to count recursion levels, static variables are the way to do it.

    Not thread-safe. Although neither was VB5/6 itself, so...



  • @Joeyg said:

    To be fair, if you have a need to count recursion levels, static variables are the way to do it.

    No, (const) parameters are the way to do it. One exception or two threads, and you can kiss your recursion level counter goodbye.



  • @TGV said:

    @Joeyg said:

    To be fair, if you have a need to count recursion levels, static variables are the way to do it.

    No, (const) parameters are the way to do it. One exception or two threads, and you can kiss your recursion level counter goodbye.

     

     This is VB 5.0! If you've got multiple threads or exceptions, you're doing it wrong!



  •  My point was actually that if you need to count recursion levels (aside from debugging code), you're likely a small child or possibly a gorilla. And neither of them use threads or exceptions.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.