Origins of WTF coders



  • Apparently the author of "<font face="verdana, arial, helvetica">C++ No Experience Required" practices what he preaches.</font>

     

    He teaches with these files, for use with Borland Turbo C++  🙂

    oh, the horror.



  • Dear God!

    He actually teaches a "course" at a "university" based on this book!

    More horror at http://www.franca.com/cmps060/



  • Since a directory listing doesn't necessarily invite casual WTFing, especially if there's zipped stuff in there and you're wondering "dudewtf, do I need to unzip stuff to WTF at it?", I suppose that http://www.franca.com/cmps060/download/files/francast.h is a good example of the WTFage.

    string::string(char *words)
    {
       if(strlen(words)<256)
       {
          strcpy(thetext,words);
       }
       else
       {
          strcpy(thetext,"String is too long");
       }
    }
    


  • OMFG!!!

    This would make Bjarne cry!



  • @fennec said:

    Since a directory listing doesn't necessarily invite casual WTFing, especially if there's zipped stuff in there and you're wondering "dudewtf, do I need to unzip stuff to WTF at it?", I suppose that http://www.franca.com/cmps060/download/files/francast.h is a good example of the WTFage.
    string::string(char *words)
    {
    if(strlen(words)<256)
    {
    strcpy(thetext,words);
    }
    else
    {
    strcpy(thetext,"String is too long");
    }
    }

     

    thats adorable...



  • @fennec said:

    Since a directory listing doesn't necessarily invite casual WTFing, especially if there's zipped stuff in there and you're wondering "dudewtf, do I need to unzip stuff to WTF at it?", I suppose that http://www.franca.com/cmps060/download/files/francast.h is a good example of the WTFage.

    string::string(char *words)
    {
       if(strlen(words)<256)
       {
          strcpy(thetext,words);
       }
       else
       {
          strcpy(thetext,"String is too long");
       }
    }
    

    The goggles, THEY DO NOTHING!



  • @fennec said:

    Since a directory listing doesn't necessarily invite casual WTFing, especially if there's zipped stuff in there and you're wondering "dudewtf, do I need to unzip stuff to WTF at it?", I suppose that http://www.franca.com/cmps060/download/files/francast.h is a good example of the WTFage.

    string::string(char *words)
    {
    if(strlen(words)<256)
    {
    strcpy(thetext,words);
    }
    else
    {
    strcpy(thetext,"String is too long");
    }
    }

    I wish I would not have seen that. Now I know I won't find sleep tonight...


     



  • ----

    The Turbo C++ compiler that you need in the class can be found through E-bay for 24.99 + 4.00 shipping. Last time I checked, there were 17 boxes available. Make sure you select the Turbo C++4.5 Windows CD. Just try to follow this link

    -----

     

    Wow, any course that requires you to buy the turbo C++ compiler has got to be terrible. 



  • Jesus Christ, this guy's teaching a 'Winter 2007' semester class with that old non-standard  garbage?   Even better, he requires the use of outdated compilers to do the coursework!

    I like these two lines:

    <font face="arial, arial, helvetica"><font face="Arial">You may also consider Microsoft Visual C++6 or 5.</font></font>


    <font face="arial, arial, helvetica"> </font>

    <font face="arial, arial, helvetica"><font face="Arial">Do not get any other compiler! They will NOT work for this class.</font></font>

    Yeah, I bet they won't.  Especially if all of the example files start with:

     void mainprog() {

        //wtf?

    }


     

     



  • mmmmm, look at the full featured classes.  None of those inconvenient search or insertion funcitons cluttering up this interface

     // this is a simplified string class for older compilers

    ...
    class string
    {
    char thetext[256];
    public:
    string();
    string(char *);
    int operator==(string &);
    int operator==(char *);
    int operator<(string &);
    int operator>(string &);
    int operator<=(string &);
    int operator>=(string &);
    string operator+(string another);
    string operator+(char *);
    string operator=(string );
    string operator=(char *);
    const char * c_str();
    int len();
    };

     



  • You can view the "class materials" directly in the download section...

    It just isn't possible to tell what the code is supposed to do.

    It's on the web page for the course that you must comment every loop and function, but his code... Well, his code must just be self-documenting, I guess.

    Oh, wait. All C++ professors pull that shit. My bad.
     



  • @shadowman said:

    Jesus Christ, this guy's teaching a 'Winter 2007' semester class with that old non-standard  garbage?   Even better, he requires the use of outdated compilers to do the coursework!

    Yeah, I lol:ed dejectedly at that. Teaching C++ in 2007 and #include:ing pre-standard libraries. And that is perhaps a minor atrocity in context... Coder Jesus weeps.  



  • @MET said:

    mmmmm, look at the full featured classes.  None of those inconvenient search or insertion funcitons cluttering up this interface

     // this is a simplified string class for older compilers



    Ouch. I was thinking this might not be so bad, it might just be an example string class to show some of the features
    of classes without getting into dynamic allocation. But it looks like the class is actually intended for use.



  • @fennec said:

       if(strlen(words)<256)
    That reminds me... We just had a bug where we weren't cleaning up an array. So my fellow "developer" went in and fixed the bug:
    count = 0; //count is how many items are in the array
    for(int i = 0; i<256; i++
    	array[i] = 0; // whatever, clear out this item
     
    I looked at this code, and I asked him "What is 256?"  He told me "its the size of the array."
    Sure enough the array is defined: int array[256];
    Great, I suggested a slightly better alternative, lets only delete the items we placed in the array. 
    And while we are at it, lets fix the possible buffer over run (the guy filling the array checks to see that we are out of bounds)
    I gave him some sample code using sizeof(array)... 
    His response: "The array is hardcoded so I don't need to calculate the size."
    !!!



  • From http://www.franca.com/cmps060/download/class%20examples/Winter2007/_jan30p1.cpp

    	 // example showing dice being thrown
    result=rand();
    result=result/32767*5+1;
    dicevalue=result+0.5;
    showresult.say(dicevalue);

     WTF.

    Has this moron not heard of modulus arithmetic?  Or constants?  Or numeric limits?  Or ANSI C for that matter...
     



  • If the array size is hard coded then why would you use sizeof(array)?!?!?!   not only is it worthless, but it's wrong.  you would have to use sizeof(array)/sizeof(type) first of all.  Second of all, just tell him to declare a constant

     #define ARRAY_LEN 256

    not only that but you suggested clearing only the items that were set.  This sounds like a lot of extra bookkeeping keeping track of which items have been set.  Why not use memset?  Before you start putting quotation marks around the word developer as an insult to your co-workers, perhaps you should examine your own answers to their problems.
     



  • @Grimoire said:

    From http://www.franca.com/cmps060/download/class%20examples/Winter2007/_jan30p1.cpp

    	 // example showing dice being thrown
    result=rand();
    result=result/32767*5+1;
    dicevalue=result+0.5;
    showresult.say(dicevalue);

     WTF.

    Has this moron not heard of modulus arithmetic?  Or constants?  Or numeric limits?  Or ANSI C for that matter...
     



    And that's a peculiar die. 1 and 6 are only half as likely as the other numbers. If he's going to weight his dice he should make them cheat properly.



  • @tster said:

    just tell him to declare a constant

      #define ARRAY_LEN 256

    That's a define, not a constant.

    const int array_length = 256;



  • @Daid said:

    @tster said:
    just tell him to declare a constant

      #define ARRAY_LEN 256

    That's a define, not a constant.

    const int array_length = 256;

     That doesn't change my point.
     



  • @tster said:

    If the array size is hard coded then why would you use sizeof(array)?!?!?!   not only is it worthless, but it's wrong.  you would have to use sizeof(array)/sizeof(type) first of all.  Second of all, just tell him to declare a constant

     #define ARRAY_LEN 256

    not only that but you suggested clearing only the items that were set.  This sounds like a lot of extra bookkeeping keeping track of which items have been set.  Why not use memset?  Before you start putting quotation marks around the word developer as an insult to your co-workers, perhaps you should examine your own answers to their problems.
     

    sizeof(array) will cause even more problems if the cleanup is done in a separate function from the original declaration of the array.  Then array is just pointer-to-int and you get the size of the pointer instead.



  • @chrismcb said:

    @fennec said:
       if(strlen(words)<256)
    That reminds me... We just had a bug where we weren't cleaning up an array. So my fellow "developer" went in and fixed the bug:
    count = 0; //count is how many items are in the array
    for(int i = 0; i<256; i++
    	array[i] = 0; // whatever, clear out this item
     
    I looked at this code, and I asked him "What is 256?"  He told me "its the size of the array."
    Sure enough the array is defined: int array[256];
    Great, I suggested a slightly better alternative, lets only delete the items we placed in the array. 
    And while we are at it, lets fix the possible buffer over run (the guy filling the array checks to see that we are out of bounds)
    I gave him some sample code using sizeof(array)... 
    His response: "The array is hardcoded so I don't need to calculate the size."
    !!!

    Guys, seriously, quit making baby coder Jesus cry. 


Log in to reply
 

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