- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
This to is a WTF. No the real WTF isn't that he reimplemented a framework function. (Maybe he wasn't allowed to use that portion of the framework, maybe this wasn't a path"
What array contruction routine are you referring to? This code constructs an array, then iterates over it to retrieve the last element. AND while its doing that, it (presumably) creates a new set of strings from each string.
Sure it might be a minor WTF, but is a WTF nonetheless.
Admin
The really funny thing is, I read this DailyWTF, then went to a program I wrote yesterday and replaced
string filename = inputFile.Substring(inputFile.LastIndexOf("\")+1);
with
string filename = Path.GetFileName(inputFile);
Admin
I like the Title of the Comments section
<title>The Long Road to Clean Up The Daily WTF - The Daily WTF</title>The Daily WTF needs cleaning up?? Surely not!
Admin
string.ToString().ToString()
you know.. just in case.
Admin
Its a multi-layered WTF:
The coder was thoroughly incompetent.
In .NET and java development it is essential to have a good grasp of the supplied libraries because they can do so much for you.
The regex I can forgive, but it is still substandard.
The looping is totally unforgivable. What sort of coder doesn't know how to access the last element of an array?
This is a worthy and sad WTF.
Admin
I guess a couple of these comments explain why there is always a certain amount of bullshit software in the windows world that just absolutely never accepts / as a path separator.
THOU SHALT NOT EMULATE UNIX
Admin
Admin
The problem of course is having documentation, that is well designed. Class maps, function defs, etc. And most importantly easily searchable. (not 50, 000, 000 hits for the word 'path').
I'm versed in several languages and several frameworks/libraries but i've really only found semi decent documentation with gnu libraries, sgi and java. No wonder that he missed it in .net .
captcha: random (hmm, does anyone think that this captcha is truly random?)
Admin
If you'd rather not use @"\", you could use "\\".
Of course, I think it's a little less obvious that "\\" will match a single backslash character.
CAPTCHA: clueless
Admin
My python code is probably wtf worthy:
in one function:
and in the other function:
I have a reason for all this though. The scripts this program parses and interprets were created in Windows and thus the files requested are in whatever case the developer cared to use. In other operating systems, filename case is important so I solve this issue by handling it all in lowercase.
Admin
I've found that the MSDN documentation for .NET is fairly reasonable, as long as you use Google to search it of course.. ;)
Admin
Another way to do what he wated in .NET (without using IO.Path.GetFileName(x)): result=parts[parts.Split("\").UBound()];
Admin
That's just horrible and wrong in so many ways. Decidedly Lovecraftian...
Admin
strrchr(fullPathName, '\') + 1;
Too bad this isn't C.
Admin
WTF is:
static { typical construct }
syntax?
C, NOT C++, programmer here, wondering...
Admin
In Java, anything you put inside a static{} block inside a class definition gets executed exactly once when the class definition is loaded from disk (arm-wavy; "loaded from disk" isn't quite right but I don't feel like checking the spec) into the virtual machine.
For example, in C, you are allowed to do this:
int foo[5] = {1, 2, 3, 4, 5};
to make a global variable with preinitialized values.
You can do pretty much the same in Java (in fact I think exactly the same syntax works). However, you can ALSO make a "global" variable (static duration and class scope) which has arbitrarily complex initialization. You can do this either by writing a method that generates the desired values, then declaring the variable as:
static int[] foo = makeFoo();
or by doing something like this:
static int[] foo; static { foo = new int[5]; for (int i = 0; i < 5; i++) foo[i] = (int) (Math.random() * 100); }
In this case, each class loader (essentially, each running copy of the program) will get ONE SINGLE list of 5 random numbers, which are guaranteed to be prepared before the variable "foo" is accessed by any "normal" means (that is, other than from another static initializer).
Admin
I think your all looking in the wrong direction.
In my experience the filename is normally shorter than the path, so go backwards:
'Get Filename off path for i=len(strPath) to 1 step -1 if mid(strPath,i,1)="" or mid(strPath,i,1)="/" then strFilename=right(strPath,len(strPath)-i) exit for end if next i
Also note that:
Admin
Or any other language.. in PHP I'd use strrpos.
Admin
i++ ????????? a slight typo, should be perhaps ptr++ ? :p
Admin
Admin
cheap NFL JerseyLewis says the Magic knew they could beat the Cavaliers in the Eastern Conference Finals when the the two teams cheap kobe jerseymet for Game 2. cheap Paul Smith ShoesIt took a miracle shot from LeBron James to beat Orlando cheap nfl jerseys cheap nfl jerseys Bucks are looking very closely at every point guard available in the draft would make youcheap g star [/url think Sessions [url=“www.cityoriginal.com”]replica jerseys walk, but it's far replica NFL jerseys, NHL jerseys too early to know. In truth, the Bucks nfl jerseysthemselves haven't f teams are starting to think about what cheap diesel [/url Villanueva would look like in their [url=“www.cityoriginal.com”]nba jerseysuniforms. One of them might be the Cleveland Cavaliers. cheap NFL Jersey mlb jerseys cheap nfl jerseys James' no-show after Game 6, we're finally getting down to business. Dwight Howard nfl jerseys [/url and Kobe Bryant will lace them up o decide [url=“www.cityoriginal.com”]cheap uggsthe best team in cheap north face jacketthe NBA. The Magic swept the season cheap jerseysseries from the Lakers, one of that feat (Charlotte was the other) cheap nhl jersey Raptors are they'd cheap tommy bahamaalso like to another selection there. With teams like L.A., Chicago, and Minnesota cheap nhl jersey [/url selling that area, they're replica [url=“www.cityoriginal.com”]NFL jerseys, NHL jerseys likely to find someone they can work with.cheap nba jersey Portland, Houston failed to shifts lebron james jersey back to Houston for Game 6 on Thursday as the Rockets scurry to make Jordan jerseysadjustments cheap nhl jerseys of the Blazers cheap ugg boots Grizzlies, and it's been mentioned that that pick could be had as well. Most teams looking to buy in are looking to buy into cheap ugg bootsthe late first/early second round. Memphis has picks potentially available in both those areas.cheap mlb jerseys Timberwolves use all three of their first round picks this year (6-18-28), and while it's all but certain they'll use cheap true religion jeanstheir #6 pick and probably the #18, that #28 could absolutely be had. For teams looking to buy into that part of the draft (see below), the Wolves cheap nhl jerseys
Admin
cheap NFL JerseyLewis says the Magic knew they could beat the Cavaliers in the Eastern Conference Finals when the the two teams cheap kobe jerseymet for Game 2. cheap Paul Smith Shoes It took a miracle shot from LeBron James to beat Orlando cheap nfl jerseys cheap nfl jerseys Bucks are looking very closely at every point guard available in the draft would make you cheap g star think Sessions replica jerseys walk, but it's far replica NFL jerseys, NHL jerseys too early to know. In truth, the Bucks nfl jerseysthemselves haven't f teams are starting to think about what cheap diesel Villanueva would look like in their nba jerseysuniforms. One of them might be the Cleveland Cavaliers. cheap NFL Jersey mlb jerseys cheap nfl jerseys James' no-show after Game 6, we're finally getting down to business. Dwight Howard nfl jerseys and Kobe Bryant will lace them up o decide cheap uggsthe best team in cheap north face jacketthe NBA. The Magic swept the season cheap jerseysseries from the Lakers, one of that feat (Charlotte was the other) cheap nhl jersey Raptors are they'd cheap tommy bahama also like to another selection there. With teams like L.A., Chicago, and Minnesota cheap nhl jersey selling that area, they're replica NFL jerseys, NHL jerseys likely to find someone they can work with.cheap nba jersey Portland, Houston failed to shifts lebron james jersey back to Houston for Game 6 on Thursday as the Rockets scurry to make Jordan jerseys adjustments cheap nhl jerseys of the Blazers cheap ugg boots Grizzlies, and it's been mentioned that that pick could be had as well. Most teams looking to buy in are looking to buy into cheap ugg bootsthe late first/early second round. Memphis has picks potentially available in both those areas.cheap mlb jerseys Timberwolves use all three of their first round picks this year (6-18-28), and while it's all but certain they'll use cheap true religion jeanstheir #6 pick and probably the #18, that #28 could absolutely be had. For teams looking to buy into that part of the draft (see below), the Wolves cheap nhl jerseys
Admin
Whats up with the spam for counterfeit fake jerseys? Cityoriginal.com sells nothing but fake counterfeit jerseys made in china. Buyer beware. Someone needs to remove this junk.