• (cs) in reply to Daniel

    And "fourteenth of November" takes longer to say than "November fourteenth".  We like to shorten our sentences as much as possible

    ...as demonstrated by the ungrammatical and ugly omission of the word "the" between "November" and "fourteenth"...? Tell me, do you refer to "Jack Ripper" or "Edward Confessor" - or perhaps "President of United States"? And perhaps the famed band should have simply been "Toad Wet Sprocket"?

     

  • (cs)

    In a way, I pity him. He doesn't have any plan, and there's no code review at his work. He probably spent weeks on this because nobody was approachable for help. And to top it all off, he never read the Spanish love story, "Manual".

    My brain is more advanced than I give it credit for. At first, it refused to see the real WTF in the post. I think it was trying to protect itself; retreating into its shell to save the processing power required to understand the poor sap who wrote this.

    My first thought was, "Well, let's see. He's probably got something like a memory leak. That's common enough, and if they open up a limit of 999 files, that's probably a quick bodge to fix the problem." (And when I use "fix" like that, I mean like when you fix a cat.)

    Then I read some of the comments, and I wondered why this was so highly regarded. Bit by bit, I saw what was going on here. I can only grok a little at a time, like sinking into the hot tub slowly to get used to the heat.

    I do have to admire the resourcefulness of this approach. He didn't know about the functions built in to C++, so he said, "Hey, I can manually call the DIR command. Then I'll capture the output as an incoming stream. Then all I have to do is parse the stream and I can get the directory contents." On the upside, it's a novel approach. The parsing is messed up beyond. ("Beyond what?", you may ask. My reply is, "yes".)

    There's not much more to say. This is a great WTF, and thank you for sharing. 

    Oh, if you're doing a file check in a do{}while(bool); loop, eventually you're going to die. You should wrap that in a while(bool){} loop. That way, if your bool is false, you won't try to open a file that isn't there. (For the cheap seats, do{}while(); will always execute once then check the condition. While(bool){} will check the condition before the initial run.)

  • SMP PREEMPT (unregistered)

    So many WTFs...

    First is using a system command to get a directory listing instead of library routines. As people have pointed out, there isn't a standard portable way to do this, but since they're using DOS commands it already only works on Microsoft systems, so using a MS-specific API wouldn't hurt. Or they could use a portable library that abstracts the platform-specific library calls away.

    The second problem is redirecting stdout to a temporary file instead of a pipe(2). What if the program crashes before it has a chance to delete the temp file? What if two instances of the program run at the same time and use the same temp file? What if you have a really large directory and the temp file fills up the disk?

    (I though up this parapgraph before I saw the post clarifying it as sarcasm, but I didn't want to wate it) The YYYYMMDD date format isn't weird; it's the only logical and unambiguous choice. DDMMYYYY also makes some sense, but it's backwards, so lexicographic order is no longer the same as chronological order. MMDDYYYY is just stupid, has no logical order and is ambiguous most of the time. You wouldn't say something like "it's 15 minutes and 34 seocnds after the 10th hour," would you? Wait, people actually do say things like "quarter after two" and "ten of." And don't get me started on the idiocy of 12-hour clocks and how so many grown people in this country are too unbelievably mentally defective to understand the alternative. Then there's the metric system... I should really stop now.

  • (cs) in reply to SMP PREEMPT

    Well, several WTF's, as some have mentioned:

    1- They have their own custom in-house language that needs its own compiler.
    2- They didn't use whatever Microsoft APIs were/are available for reading a directory, relying instead on the output of some other program that had to use said APIs.
    3- They weren't using an OS that provided opendir(), readdir(), and closedir() like any sane person would expect.
    4- They again relied on an external command, 'DEL', to delete files instead of doing it programmatically.  Surely MS-Windows provides a way to delete files without some sort of crazy moon code inserted in 2 loops.
    5- Nutty file naming schemes.
     

  • Richard Head (unregistered) in reply to SMP PREEMPT

    Apparently none of you can pick up sarcasm.  The note about Hank being weird for still liking YYYYMMDD is sarcastic.  But then again I'm weird and think people should be forced to have a license before having kids.
     

  • qbolec (unregistered) in reply to JamesCurran
    C:\Documents and Settings\Administrator>dir
     Wolumin w stacji C nie ma etykiety.
     Numer seryjny woluminu: B487-C8AE
    
     Katalog: C:\Documents and Settings\Administrator
    
    2006-10-23  07:48       <dir>          .
    2006-10-23  07:48       <dir>          ..
    2006-10-28  09:14       <dir>          .idlerc
    2006-10-03  08:57       <dir>          Application Data
    2006-09-23  08:49                  614 contestapplet.conf
    2006-11-07  10:58                8 549 gsview32.ini
    2006-11-14  17:55                   12 intlname.ols
    2006-08-17  12:07       <dir>          Menu Start
    2006-11-02  12:29       <dir>          Moje dokumenty
    2006-11-14  10:21       <dir>          Pulpit
    2006-11-12  15:24       <dir>          Ulubione
    2006-08-21  13:56       <dir>          VSWebCache
    2006-09-27  23:33                   63 _ipecfg
     
    So there is  no "D" nor "/" at all. Well - I know, they probably won't use "home coocked compiler" in Poland...but still - why would they expect the path to have no spaces inside?
    
  • gl (unregistered) in reply to SMP PREEMPT
    Anonymous:

    So many WTFs...

    First is using a system command to get a directory listing instead of library routines. As people have pointed out, there isn't a standard portable way to do this, but since they're using DOS commands it already only works on Microsoft systems, so using a MS-specific API wouldn't hurt. Or they could use a portable library that abstracts the platform-specific library calls away.

    The second problem is redirecting stdout to a temporary file instead of a pipe(2). What if the program crashes before it has a chance to delete the temp file? What if two instances of the program run at the same time and use the same temp file? What if you have a really large directory and the temp file fills up the disk?

    (I though up this parapgraph before I saw the post clarifying it as sarcasm, but I didn't want to wate it) The YYYYMMDD date format isn't weird; it's the only logical and unambiguous choice. DDMMYYYY also makes some sense, but it's backwards, so lexicographic order is no longer the same as chronological order. MMDDYYYY is just stupid, has no logical order and is ambiguous most of the time. You wouldn't say something like "it's 15 minutes and 34 seocnds after the 10th hour," would you? Wait, people actually do say things like "quarter after two" and "ten of." And don't get me started on the idiocy of 12-hour clocks and how so many grown people in this country are too unbelievably mentally defective to understand the alternative. Then there's the metric system... I should really stop now.

     

    You're right about the 12-hour clocks.  We should switch to the old Japanese system of 6 equal time periods during daylight and 6 during darkness, with each day's "hours" changing in length as the seasons progressed.  Also, count the "hours" backwards from 9 to 4 and don't use 1 through 3.  (Their clockmakers were mechanical geniuses to create clocks that could track this system).

  • (cs) in reply to jesperdj
    jesperdj:

    I haven't tried to analyze the code, but ofcourse the REAL WTF here is:

    ...the custom compiler they wrote for their in-house language...

    I wonder why the job they had to do was so special that it required a custom programming language. 

    I can only imagine they're working on some kind of video game or otherwise extensible environment where they want the public to be able to access inner features. This would explain why the code was apparently written by an intern.

  • gl (unregistered) in reply to qbolec
    Anonymous:
    <snip>
    but still - why would they expect the path to have no spaces inside?
    

     Just a guess, the code looks like it might have been written in an MS-DOS system (or possibly IBM-DOS for those that are pedantic).  The earlier versions did not allow spaces in file names.  My memory is failing me, I don't remember the version that started allowing long filenames.

  • JL (unregistered) in reply to SMP PREEMPT

    Anonymous:
    And don't get me started on the idiocy of 12-hour clocks and how so many grown people in this country are too unbelievably mentally defective to understand the alternative. Then there's the metric system... I should really stop now.

    Absolutely.  I, too, fail to understand why the U.S. never adopted metric time...  I mean, it's the only system that makes sense!  For example, if someone asked me how many seconds there are in seventeen and a half days, I can readily answer "1,750,000 metric seconds".  Try asking an American the very same question, and he'll look at you like you're an idiot!

  • segmentation fault (unregistered) in reply to JamesCurran
    JamesCurran:

    The "if (tmpstr[1] == 'D')" catches the line in the header which looks like this:
       Directory of C:\Documents and Settings\jamescu

    ..

    The "if(tmpstr[2] == '/')" catches line in the body whch look like this:


    ...

     

     

    oh i see now.

     

    i dont know whats worse me for not spotting that or him for doing something i wouldnt even think of. 

  • Sarusa (unregistered)

    I never thought I'd say this but...

    I'm going to have to stop reading the comments on these. You people are scaring the hell out of me. Even more than (most) slashdot commenters.

     

  • (cs)

    If the original coder really felt it was necessary to use the DOS "Dir" command to get a list of files, why not also use the "/b" flag and get a list with no header information, etc., to strip out?

    Since I'm not clear on what the code is supposed to do other than get a list of file names, not being a C++ coder, I'm quite probably missing something on that.  And, of course, I'm ignoring other errors pointed out by other people in the forum here.  But still, if you just want a list of files in a directory, without the header, etc., you can use "dir /b" and just get file names and extensions, with nothing to parse at all.  If you need them sorted by date order, "dir /b /o:d" will do that for you too.  This is assuming (as mentioned), that you positively have to use the DOS "Dir" command at all.

    "/o:d" would mean you don't have to parse out file dates to figure out which one is first.  Oldest file is first, newest is last.  Simple as that.

    I'm sure there are better methods for doing these things in C++, but if you don't know/can't use those, why not actually use the Dir command's flags to do part of the work for you?

  • tamosius (unregistered) in reply to Jon Haugsand
    Anonymous:

    The ISO standard is actually YYYY-MM-DD, which is both easy to read, maintain sortability and unambigouness.  What <i>really</i> bothers me is how it is possible to come up with the MM/DD/YY date format idea in the first place.

     - Jon

    100% agree...

    anyone disagreeing with that, guess what '01/02/03' really means...

  • (cs) in reply to Jon Haugsand
    Anonymous:
    Anonymous:

    Tim Gallagher:
    Hank is one of those weird people who thinks that dates should be YYYYMMDD format.

    I'm with hank on this one, sorting a date in YYYYMMDD format is easier that sorting a date in DDMMYYYY or MMDDYYYY. And also for the international community, it is easier to read.

    as for everything else the problem is the guy who wrote this doesn't know the stdc libary that well.

    he could of just used the dirent interface which is platform independant. (i think, wrote a simple program using the interface in Borland C++ and it worked) .

     The ISO standard is actually YYYY-MM-DD, which is both easy to read, maintain sortability and unambigouness.  What <i>really</i> bothers me is how it is possible to come up with the MM/DD/YY date format idea in the first place.

     

     - Jon

     


    Couldn't agree more (with both Hank & others). YYYYMMDD is the way to go :)
  • (cs) in reply to SMP PREEMPT

    Anonymous:
    ...don't get me started on the idiocy of 12-hour clocks and how so many grown people in this country are too unbelievably mentally defective to understand the alternative.

    Yes, I too enjoy believing that people are mentally defective when they a) don't agree with me or b) don't care about what I'm proposing.  This makes me feel much better about myself, especially when I consider how unbelievably mentally defective (and otherwise inferior to me) they all are.

  • Kiss me, I'm Polish (unregistered) in reply to KoFFiE

    Let's vote. We will choose that way the right way of writing date and time. No more mm/dd/yy, dd.mm.yy, yy.dd.mm or even ym.dy.md. And while we're at it, let's adopt only latin month names, because most of the world uses them. And the windows task bar MUST be at the bottom. This is where it belongs, because almost everybody keeps it there (yes, me too). We'll live then in the perfect, democratic world, and if someone has the stupid idea of writing dates as he's used to, we'll be able to point him right here, to this thread, where we chose how's it gonna bee. This might be even a historical moment we're in.

    OK, enough crap.

    If some other countries use different notations, or alphabet or anything, well - deal with it. Nobody asks your point of view about how they should write dates, because nobody cares - you're not the expert! You're the coder, and all you have to do is write stuff in such way that it works in U. S. as well as in France or even Kazakhstan. You don't like it - then maybe you should consider getting another job, like The Date Preacher

  • Achille (unregistered) in reply to JamesCurran
    JamesCurran:

    Anonymous:
    The ISO standard is actually YYYY-MM-DD, which is both easy to read, maintain sortability and unambigouness.  What <i>really</i> bothers me is how it is possible to come up with the MM/DD/YY date format idea in the first place.

    The convention of putting the year last was started several hundred years before anyone thought of devising a mechanical process for sorting.

    In other terms:

    • DD-MM-YYYY    -    Little Endian
    • MM-DD-YYYY    -    Middle Endian
    • YYYY-MM-DD    -    Big Endian
  • Dwayne (unregistered) in reply to blaaaaaaaaaaaaa
    blaaaaaaaaaaaaa:
    DanielJC:
    Dwayne:

    Speaking of WTFs, who's the idiot that designed the FindFirstFile/FindNextFile interface in the first place?  Yeah, that's real convenient to use in a loop

    Are you actually being serious? If so, your programming knowledge let alone API knowledge is severely deficient!

     I agree with Anon... compare the STL iterator

    for (SessionMap::iterator j = m_sessions.begin(); j != m_sessions.end(); ++j)
       {
     //do something with *j

    }

    or the Design Patterns iterator:

    CIDIterator i = p->GetIDIterator();
    for (i.First(); ! i.IsDone(); i.Next())
    {
    // do something with i.CurrentItem();
    }

    This is exactly what I'm saying, thank you.  The STL iterator style or open/read/closedir trio is a much less awkward design.  FindFirst/FindNextFile works, but it's clumsy and annoying.

  • Dwayne (unregistered) in reply to Achille
    Achille:
    JamesCurran:

    Anonymous:
    The ISO standard is actually YYYY-MM-DD, which is both easy to read, maintain sortability and unambigouness.  What <i>really</i> bothers me is how it is possible to come up with the MM/DD/YY date format idea in the first place.

    The convention of putting the year last was started several hundred years before anyone thought of devising a mechanical process for sorting.

    In other terms:

    • DD-MM-YYYY    -    Little Endian
    • MM-DD-YYYY    -    Middle Endian
    • YYYY-MM-DD    -    Big Endian

    Except that in this case, one of the alternatives (the last, as it happens) is unambiguously and objectively better than the others.  If only the actual endianness arguments were so easy to resolve.

  • (cs) in reply to SMP PREEMPT
    Anonymous:

    The YYYYMMDD date format isn't weird; it's the only logical and unambiguous choice.

    But logical and unambiguous is irrelevant.  Everyone grows up learning one way of doing dates, which makes it extremely difficult to unlearn later in life.  No one ever formed a committee of government idiots to decide how to do this, these are conventions that formed over time, long before computers.  To say "Americans are stupid for doing it this way" is pretty ignorant about how such stuff works.  The rules can't be changed easily, because it'll cause tons of confusion.

    I mean the French had to a bloody revolution in order to get their system straight (and even then they eventually backslid and reverted to the illogical calendar of 12 unequal months).


    For me, if the year comes first, then I always assume "YYYY-MM-DD", if the year comes last, it's
    MM-DD-YYYY".  Thank heavens people are using 4 digit years.

    To add some extra confusion, work in America is done referring to dates; as in "I'll finish this project on December 9th" or "Let's have a meeting the second week of April."  When I worked for a Finnish company, they used week numbers "I'll be on vacation during week 46".  This really caused confusion to us American workers, since no one had calendars with week numbers on them.  Some computer calendars can do this if you enable the option and choose which of several options decides week number one.  So whenever someone would ask "you're flying out on week 32, correct?" I'd scramble to do the math in my head before answering.  (I don't know if other countries do this)

  • (cs) in reply to mleh
    mleh:

    1- They have their own custom in-house language that needs its own compiler.

    This is quite common.  It's often hard to find a suitable embedable scripting language.  Especially in the past.  I worked at a company once that did this, and the language was intended for end users to add simple code to forms.  So the language couldn't be too complicated, we added our own sanity checks, and it was tied to the capabilities of our project.  Someone today would say "dude, just use TCL" (or VB or whatever), but none of those would really have fit the bill, even if they had existed.

    mleh:


    3- They weren't using an OS that provided opendir(), readdir(), and closedir() like any sane person would expect.

    That routine may have been a part of a portability layer. We aren't told.

  • Wuggy (unregistered) in reply to darin
    darin:
    Anonymous:

    The YYYYMMDD date format isn't weird; it's the only logical and unambiguous choice.

    But logical and unambiguous is irrelevant.  Everyone grows up learning one way of doing dates, which makes it extremely difficult to unlearn later in life.  No one ever formed a committee of government idiots to decide how to do this, these are conventions that formed over time, long before computers.  To say "Americans are stupid for doing it this way" is pretty ignorant about how such stuff works.  The rules can't be changed easily, because it'll cause tons of confusion.

    I mean the French had to a bloody revolution in order to get their system straight (and even then they eventually backslid and reverted to the illogical calendar of 12 unequal months).

    As long as developers stick to iso8601 ordering, then we get simplicity where it's needed. What should happen is that dates should be stored in a nice, simple, consistant, logical and internation standards mandated way, with all of the orderings that are done in various locations are done through localisation. It's fantastic! You get to have a nice simple way of ordering stuff when you're looking under the hood, whether it be in flat files, a funky database or whatnot, and you let your users all over the world use the date system they're familiar with even if it's in "moon_phase +/- high_tide_count" format.

    Unless of course, you don't think American /developers/ are smart enough to do localisation...

  • Greg (unregistered)

    Who's the goofy guy that writes "later" as "latter"?

  • (cs) in reply to djork

    7 June 2006 is nicer because:

    1. the two numbers are sepearated by a word
    2. It goes, conssitently, from the most variable value to the least (days change more often than months)
    Cheers
  • Anon (unregistered)

    I like how he tries to strcat a file pointer.

  • wyz (unregistered) in reply to gl

    My thought also, this is from days when DOS limited file names to 8.3 format.

     From memory spaces were allowed in file names when MS changed from FAT (16 bit) to FAT32 with Win95.

  • (cs) in reply to gwenhwyfaer
    gwenhwyfaer:

    And "fourteenth of November" takes longer to say than "November fourteenth".  We like to shorten our sentences as much as possible

    ...as demonstrated by the ungrammatical and ugly omission of the word "the" between "November" and "fourteenth"...? Tell me, do you refer to "Jack Ripper" or "Edward Confessor" - or perhaps "President of United States"? And perhaps the famed band should have simply been "Toad Wet Sprocket"?

     

    You know, "Toad Wet the Sprocket" would be a great name for a band (if that other band didn't sue).  They could sing Kenneth Grahame poetry.

  • AD (unregistered) in reply to EvanED

    As noted, the for loop version using Find*File failed to check the return value of FindNextFile.  You're looking for something closer to this:

    HANDLE search;
    BOOL keepgoing = TRUE;
    for(search = FindFirstFile("dirpath", &data);
            search != INVALID_HANDLE_VALUE && keepgoing;
            keepgoing = FindNextFile(search, &amp;data))

    {
        ...
    }
    FindClose(search);

    Because FindFirstFile and FindNextFile signal file-not-found in different ways, but both potentially return a directory, there is no single check that will check both.  It's not too bad, but it's verbose and less obvious than the STL iterator interface or the opendir/readdir.

  • Rich (unregistered) in reply to darin
    darin:

    (I don't know if other countries do this)

    Yes they do. And there is more than one way of determining the week number.

     

    Rich 

  • (cs) in reply to Wuggy

    Anonymous:

    Unless of course, you don't think American /developers/ are smart enough to do localisation...

    Of course developers can do that.  They are doing that (usually).  The issue in question is about why do people use dates in a non-logical way, not why are computers programmed to use dates in a non-logical manner.

    Dates and times usually never stored in a readable format anyway; they're stored as some internal and opaque data type, and converted to a readable format when necessary.  It's just as silly to store a date internally as 8 characters of YYYYMMDD as it is to store MMDDYYYY.  Better to use time_t, Julian dates, etc.

  • jayh (unregistered) in reply to SMP PREEMPT
    Anonymous:

    ..... MMDDYYYY is just stupid, has no logical order and is ambiguous most of the time....

     

    It has historic roots, long pre computer. Colloquial speech frequently was just month and date, the year designator was only added when it was significant. This carried over into notation

  • (cs) in reply to blaaaaaaaaaaaaa
    Anonymous:
    Anonymous:
    Anonymous:

    Speaking of WTFs, who's the idiot that designed the FindFirstFile/FindNextFile interface in the first place?  Yeah, that's real convenient to use in a loop

    Are you actually being serious? If so, your programming knowledge let alone API knowledge is severely deficient!

     I agree with Anon... compare the STL iterator

      for (SessionMap::iterator j = m_sessions.begin(); j != m_sessions.end(); ++j)
       {
     //do something with *j

    }

    This is bug-humpin' ugly from a performance standpoint, since m_sessions.end() is recalculated every time.

     

    or the Design Patterns iterator:

    CIDIterator i = p->GetIDIterator();
    for (i.First(); ! i.IsDone(); i.Next())
    {
    // do something with i.CurrentItem();
    }

    This doesn't really "go about its business in a line or two" because there's way more code backing up  i.First(), i.isDone(), etc., than you actually need.  Worse, they're method/function calls, with associated overhead.  The STL really is an academic's approach to a problem (Stepanov is an academic, not an in-the-trenches coder), and academic approaches are almost never optimal. 

    Actually, I hate the STL.  It's a friggin' licorice, mustard, and gorgonzola sandwich on pumpernickel-raisin rye, with a side of cream of aspargus soup and a brusselsprout salad.

    I'm a heretic, I know.  Someone has to be.

  • (cs) in reply to blaaaaaaaaaaaaa
    Anonymous:
    Anonymous:
    Anonymous:

    Speaking of WTFs, who's the idiot that designed the FindFirstFile/FindNextFile interface in the first place?  Yeah, that's real convenient to use in a loop

    Are you actually being serious? If so, your programming knowledge let alone API knowledge is severely deficient!

     I agree with Anon... compare the STL iterator

      for (SessionMap::iterator j = m_sessions.begin(); j != m_sessions.end(); ++j)
       {
     //do something with *j

    }

    This is bug-humpin' ugly from a performance standpoint, since m_sessions.end() is recalculated every time.

     

    or the Design Patterns iterator:

    CIDIterator i = p->GetIDIterator();
    for (i.First(); ! i.IsDone(); i.Next())
    {
    // do something with i.CurrentItem();
    }

    This doesn't really "go about its business in a line or two" because there's way more code backing up  i.First(), i.isDone(), etc., than you actually need.  Worse, they're method/function calls, with associated overhead.  The STL really is an academic's approach to a problem (Stepanov is an academic, not an in-the-trenches coder), and academic approaches are almost never optimal. 

    Actually, I hate the STL.  It's a friggin' licorice, mustard, and gorgonzola sandwich on pumpernickel-raisin rye, with a side of cream of aspargus soup and a brusselsprout salad.

    I'm a heretic, I know.  Someone has to be.

  • (cs) in reply to JL
    Anonymous:

    Anonymous:
    And don't get me started on the idiocy of 12-hour clocks and how so many grown people in this country are too unbelievably mentally defective to understand the alternative. Then there's the metric system... I should really stop now.

    Absolutely.  I, too, fail to understand why the U.S. never adopted metric time...  I mean, it's the only system that makes sense!  For example, if someone asked me how many seconds there are in seventeen and a half days, I can readily answer "1,750,000 metric seconds".  Try asking an American the very same question, and he'll look at you like you're an idiot!

    I believe the trains in Springfield run on metric time.

    "Remember this time people, 80 past 2 on April 47th, it's the dawn of an enlightened Springfield."

     

  • Rich (unregistered) in reply to mrprogguy

    The issue with FindFirstFile is that it bundles the action of FindNextFile in totally unnecessarily. Who on earth would actually want to "Find the First File" anyway? It's a pointless function with a pointless bundling. It means that the two functions are tied in ways that simply don't make sense and make it hard to do certain programming actions (For example, it would be awkward to use FindFirstFile outside of a function and then pass the result to a function that looped over FindNextFile).

     As for do loops, they're OK in their place but in my book, while is always preferred for readability and I'll often sacrifice "Gee whizness" for readability

    Rich
  • (cs)

    Ok ignoring the fact that he uses system calls, outputs a frivilous error message and closes ALL of the open streams, isn't localizeable, doesn't use any sort of dynamic array (WTF we had to wait for std in c++ to get dynamic arrays?), doesn't work with 'newer' long names,  among other problems...

    This seems to MOSTLY work. BUT WHY remove the last character of the path and file names?

  • (cs) in reply to jesperdj
    jesperdj:

    I haven't tried to analyze the code, but ofcourse the REAL WTF here is:

    ...the custom compiler they wrote for their in-house language...

    I wonder why the job they had to do was so special that it required a custom programming language. 

    I used to work at a place which was a web app development house for a perticular type of business. Once there was a guy management interviewed to hire as programmer who promised to create wizard for the development of web site. Till this part everything was fine...

    He continued with the promise and said..... I will write a custome programming language in VB.Net and on the new programming language I will write the wizard to create web site.

    The best WTF was he got HIRED by the management and after 6 months full of whole bunch of nothings he got FIRED by the same management.

     

     

     

     

  • JL (unregistered) in reply to chrismcb

    chrismcb:
    This seems to MOSTLY work. BUT WHY remove the last character of the path and file names?

    Stripping off the carriage return, maybe?

  • Sarusa (unregistered) in reply to mrprogguy

    mrprogguy:

    Anonymous:

     I agree with Anon... compare the STL iterator

      for (SessionMap::iterator j = m_sessions.begin(); j != m_sessions.end(); ++j)
       {
     //do something with *j

    }

    This is bug-humpin' ugly from a performance standpoint, since m_sessions.end() is recalculated every time.

    ... 

    This doesn't really "go about its business in a line or two" because there's way more code backing up  i.First(), i.isDone(), etc., than you actually need.  Worse, they're method/function calls, with associated overhead.  The STL really is an academic's approach to a problem (Stepanov is an academic, not an in-the-trenches coder), and academic approaches are almost never optimal. 

    What? No it isn't recalculated every time. Nor are they method/function calls. The key to C++ is that all these tiny little calls are inlined where possible. If your compiler sucks, as all C++ compilers used to, then your produced output will by abyssmal indeed. But if you're using g++ or msvc in release mode it'll do the right thing these days. Your  j != m_sessions.end() works out to two memory locations being compared right inline.

    C/C++ people are obsessed with speed and memory efficiency. STL is fugly compared to the much nicer ways you can do all this stuff in ruby/python/whatever (or even java containers now, to a point), so you'd better get something in return.  For instance the rampant non-orthogonality is due to performance concerns.

    It's worth noting that every attempt I've seen to reinvent what the STL does ends up being slower and broken in various ways. There have been a lot of people looking very hard at the various major STL implementations for a long time. It just ends up the same as when people try to redo bits of stdlib.

     

    mrprogguy:

     I'm a heretic, I know.  Someone has to be.

     Uh... yeah. There are plenty of things you can complain about with the STL, perhaps you could go after something a little more fruitful?

     

  • Anonymous P.M. Doubleday (unregistered)

    Hmmm, maybe I should have tried harder to cut&paste through this delightfully Byzantine interface.  Oh well.

     It's time you guys got back to talking about WTFs and what WTFiness is; possibly even to start a crusade, or even a jihad (I'm platform neutral on this one) to seek out WTFosity and to temper the misguided and sinful WTFness of those poor souls who write ...

     ... something ...

    .. like THIS?

     I did, honestly, read down the list of comments (88 at my count), and I did pay attention to the various gripes and point-scoring about this interface or that interface, or scripting, or whatever else, but let's get down to the mat with this one.  This is actually a classic WTF, in the sense that you really don't need to know C (and I ignored C++ whilst my eyes bled, for fairly obvious reasons if you read the code).  You barely even need to know programming.  This is just <i>so</i> wrong.

     What I found funny (and I hope this doesn't sound rude to the commenters involved, because I actually know what they mean) is that several people actually tried to compile this steaming pile of mammoth dung, just to check (a) what the 'D' is for -- no, I have no idea either, but five seconds' contemplation is enough to tell me that I don't really want to find out -- or (b) what the "edge cases" might be, that cause this *thing* to fail.

     Edge cases? Pah! Tell that to Christopher Columbus. ("Too many files to process! Aaargh....)

    So, let me see. Where, exactly, is the WTF here?

     Well, we've got (in, apparently, C++), strcpy, strcat, strcat, oops did I check argument count, strcat, system()  **5 STAR FIRE ALARM**, creation of a temporary file (Beware! Goblins!), arbitrary-looking while loop, and, well, this is kind of where I stop.

     Forgive me Father, for I have sinned.  I am a Maintenance Programmer.  Apparently I was a very, very naughty cockroach in my previous life.

     That if()..else ()... stuff doesn't make any sense.  Where's the default? Does it need a default? Is it assembly language, dressed up as C(opt++)? Why would I even <b>care</b> what it's doing, even if it happens to be running a small nuclear reactor sited next to my head?

     In short, this is, and it very definitely <i>is</i>, a WTF because it's butt-ugly and cretinous.  Just look at it.

    And then look away.

     You'll feel better.

  • (cs) in reply to SMP PREEMPT

    Anonymous:
    ...DDMMYYYY also makes some sense, but it's backwards, so lexicographic order is no longer the same as chronological order. MMDDYYYY is just stupid, has no logical order and is ambiguous most of the time....
    <font size="+1">D</font>DMMYYYY and MMDDYYYY are ambiguous exactly 132 out of 355 (356) days of the year.

     

  • (cs) in reply to Kiss me, I'm Polish

    The Mars orbiter is rolling in its grave.

  • Brendan (unregistered)

    enough talking about the date formats. Something I have just noticed. The code says that is can support folders containing up to 999 which in fact it only soupports up to 997, due to the '.' and the '..' directories.

    i've just worked out what the line 'else if(tmpstr[2] == '/')' does.

    It's part of the date, for example

    01/12/2006  .... <DIR>  .

       ^

  • (cs) in reply to mrprogguy
    mrprogguy:

    Actually, I hate the STL.  It's a friggin' licorice, mustard, and gorgonzola sandwich on pumpernickel-raisin rye, with a side of cream of aspargus soup and a brusselsprout salad.

    I keep running across code from people that seem to know nothing but STL and can't figure out how to code without it.  I've seen code that used stl::map where the keys were an enum with only 10 possible values.  I've seen maps where the code clearly never stored more than one item at a time.  Both on a system with limited memory.

    I've seen similar misuse of std::string.  Now I like std::string, when used right.  But people apparently use the toolkit they know, whether it fits the job or not.  I've actually seen this code (names changed to protect the innocent):

        static const std::string Keyword("keyword");
        ...
        bool IsKeyword( const char* cmd )
        {
            string cmdStr(cmd);
            return (Keyword.compare(cmdStr) == 0);
        }

    To be fair, I've also found the opposite to be true, where only the C functions are known, as in (I am not making this up):

       strlen( pathname.c_str() );

  • Div (unregistered) in reply to triso
    triso:

    <font size="+1">D</font>DMMYYYY and MMDDYYYY are ambiguous exactly 132 out of 355 (356) days of the year.

    Since when did a year have 355 or 356 days? 

  • (cs) in reply to Rich
    Anonymous:

    The issue with FindFirstFile is that it bundles the action of FindNextFile in totally unnecessarily. Who on earth would actually want to "Find the First File" anyway? It's a pointless function with a pointless bundling. It means that the two functions are tied in ways that simply don't make sense and make it hard to do certain programming actions (For example, it would be awkward to use FindFirstFile outside of a function and then pass the result to a function that looped over FindNextFile).

     As for do loops, they're OK in their place but in my book, while is always preferred for readability and I'll often sacrifice "Gee whizness" for readability

    Rich

    The FindFirstFile/FindNextFile interface was based on DOS's findfirst and findnext system calls, which in turn were based on CP/M BDOS functions 17 and 18. In those days everybody wrote in assembly language, and the do/while loop is actually the easiest kind to write in assembly.

  • C Serpent (unregistered) in reply to Goplat

    > dirent is a Unixism.

    Yes, but it has been in the POSIX standard for about a decade and was widely-ported (even to such things as CPM) a decade before that.

  • Earl Purple (unregistered) in reply to mrprogguy

    That is the wrong way to loop through a collection in STL though. The correct way is to use an algorithm.

    std::for_each( m_sessions.begin(), m_sessions.end(), functor );

    It took Java up to version 5 to add Generics, finally realising that it's a good idea. It even optimises the bounds checking, since if iterating through a Java collection like:

    for( Obj o: myContainer )

    {

     // do whatever

    }

    there is no need to bounds-check your way through.

     

     

  • (cs)

    Is it just me, or does this chop off the last character of the string?

    j = strlen(tmpstr); tmpstr[j-1] = 0;

    Seems to me he's trying to null-terminate an already null-terminated string, and in the process removing the last character.

    Maybe I just read it wrong (not enough coffee this morning). 

Leave a comment on “Please Select Fewer Files”

Log In or post as a guest

Replying to comment #:

« Return to Article