- 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
Admin
I haven't read all the comments, but I don't blame him at all. I'm not anti-Microsoft, I work for a company that writes clients and servers that exclusively work under Windows, much of which is written in C#, but I've had to work a little bit with Office interop, and it is disgusting, painful and mindbendingly terrible.
Admin
The submitter should have included the size of the company with the article. If it's a shop of 20 guys, it's not that bad. But if you work at a large corporation, at least some professionalism should be expected, and if it's not there, you can end up triggering the pinkSlip() event. Although it's not unprecedented: http://www.kuro5hin.org/story/2004/2/15/71552/7795
Regardless, I'd like to see his thoughts on how Excel handles dates.
Admin
But seriously, using a spreadsheet as a database is a recipe for headaches. I can use a spoon to dig a hole and a shovel to eat my cereal, but I should expect things not to work out very well.
That's not to say that Excel isn't a WTF....it is still the only Office application that still uses a single window for all open files/workbooks, which makes comparing two Excel files side by side impossible. (I forget why I needed to do that once, but it is 2012 and I still can't.)
Admin
Admin
Admin
And RIGHT$() is only efficient if the string is implemented with a length value. Not positive it could be used here, just heading off the argument it could be used in the IF: it probably would still scan the string just to find the end. Though if it exists it could be used, IF you trust there not be other $s that could be problems. Personally, I'd rather be sure than save some microseconds.
Pre-scanning a string before a replace is demonstrably a waste of time IF what you are scanning for could be at an unknown location. Conversely, using REPLACE for anything known only to be at the start of a string would be a waste.
Admin
I am almost certain that Excel was invented in-house. There was actually a Mac version in the 80's before a Windows version and it was so good, it has been credited with saving the Mac from oblivion. I would imagine that the guts of much of the Excel OLE Automation libraries has not changes since the early 1990's.
I also remember from the 1990s a guy who saw some Windows code said he saw a comment something like "This has to be this way or Excel won't work"
Admin
But even if that weren't available, they are still MDI apps, which means you can view the child windows side-by-side. There are no hoops involved.
Admin
Oh, I get it. The WTF is that Paul failed to recognize the infallibility and general awesomeness of Microsoft, right?
Admin
It's often easy to see what a piece of code DOES. Understanding WHY it does it can be the trick. And if a later programmer doesn't know why the code is doing something, at best he may struggle to figure it out. At worst he might think it's a mistake and remove it when in fact it's correct.</billygoat-gruff>
Admin
Admin
Yeah, what he said.
Every now and then I see code comments of this sort:
And I can only think, Uh, yeah, thanks for clearing up what a plus sign does. I was having trouble figuring that out.
Left unexplained is what "fcv" is, and what the significance of the number 137 is.
A useful comment would be something more like, "Convert Fluc Capacitor Voltage from Newtonian to Liebniz scale".
Admin
Leave IBM out of this! cries
Admin
There is no WTF here. If you've ever worked with Excel via either the COM interop or the OLE-DB adapter, you would realize that the author of the code is 100% correct.
The name of each worksheet in a workbook sometimes requires a $ and sometimes does not. It is a huge pain in the ass that's extremely inconsistent and error-prone.
In my opinion, Excel should never be used as a database. The only [legitimate] reason to access it programmatically should be to port data to a different [better] format. Unfortunately, people who don't realize this continue to believe that Excel is a great way to store data.
CAPTCHA: plaga -- Programmatic interaction with Excel is a cancerous plaga on businesses; it always results in death and destruction.
Admin
Admin
(Except that I don't forget to mention those tendencies...)
Admin
This overwrites the default DDE method of opening a .xlsx with the command line method; now when you double-click an Excel file, it will open in a new window.
Admin
ZOMG, WTF - the comments are longer than the code!!
Admin
I certainly prefer my own $$$ to Micro$oft'$!
Admin
I wonder if this is a similar problem to what I am seeing with tagging photographs. Microsoft has somehow decided that dates that resolve to the day, must also include the time. So, if you say a photograph is 12/3/1998, and the time you tag it is 9:28pm, then the photograph will be tagged as having been taken 12/3/1998 9:28pm.
For those who say a datetime field must have a time, I personally would have chosen 0:00 as the default in this circumstance for several obvious reasons.
Admin
Jon Walker (of AutoDesk)'s "The Hacker's Diet" includes Excel spreadsheets for performing the statistical tracking on daily weight measurements that he advocates in the book:
http://www.fourmilab.ch/hackdiet/comptoolsExcel.html
He has versions for Excel 2.1, 4.0, 5.0, 7.0, 97, 2002, and 2003. And a note as to why there are so many versions:
Why So Many Versions?
The Hacker's Diet spreadsheets were originally developed in 1990 with Excel 2.1 on Microsoft Windows 3.1. Some of the components in the package use Excel macros which are, for the most part, relatively simple and straightforward compared to those found in a typical corporate Excel application. Nonetheless, thanks to Microsoft's practice of “strategic incompatibility” and utter contempt for the investment made by their customers, these rudimentary macros have required specific modifications for every single new version of Excel in the decade since they were originally released, and things have gotten worse, not better, since Microsoft introduced the new Visual Basic programming language for Excel (itself a cesspool of release-to-release incompatibility), due to what appears to be a deliberate Microsoft strategy to destabilise the original macro language in order to force customers onto the new one (at a cost to Microsoft corporate clients I estimate on the order of a hundreds of millions of U.S. dollars).
The upshot of this is that while in a reasonable world spreadsheets and macros would be capital, created once and then used thereafter with no additional attention, in the world of Microsoft, software developed for their platforms is a “wasting asset” more like a stock option with an strike date about 18 months from the time it was developed. By then Billy Boy or one of his Kode Kiddies will have changed their mind about something (or simply introduced a gratuitous incompatibility, whether for strategic reasons, due to sloppiness or incompetence, or just for the Hell of it) which pulls the carpet out from under the application and its users when they “upgrade” to a more recent Microsoft release (which is increasingly involuntary as more and more new computers are sold pre-loaded with the latest releases of Microsoft operating systems and applications, offering the customer no option but to pay the “Microsoft Tax” bundled in the cost of the system).
Admin
ObOT: The comment in the article is not a WTF.
Admin
Oh Lordy. I just started on a project that is supposed to generate its output to Excel. I don't have warm fuzzies anymore :-(
Admin
"Ours is not to reason why. Ours is but to do and die"
Admin
Yes I'll bite (probably not the first but I'm not reading through all this shit).
The purpose of a comment is not so much to explain what a piece of code does as to explain why it does it. Otherwise someone's going to say: "You delete the $ off the end and replace it? What rubbish! I'm deleting this because it clearly does nothing!"
I agree. Paul is all right, for all the reasons stated.
Admin
The true waste of time is caring about optimization for such a lightweight function. It's not like this is done a million time inside a loop or takes more than a hundredth of a second. I'd be more worried about the fact that I just ran a test in Excel, and you can have dollar signs in the workbook name. The worst inefficiency is a bug...
Admin
I sense a company going down the gutter, screaming along the way "but we were right! We were right all the time!"
Admin
Apparently MSJet is so named because it both sucks and blows.
Admin
Well, almost.
The original comment probably wasn't a WTF. The version in the article probably was, because someone toned it down to be safe for work even though its full honest goodness deserves to be posted on The Daily What The Fuck.
Admin
Admin
At least he was kind enough to comment his code!
Admin
That's time saver in the long run...
Admin
These comments are completely legitimate. I am glad they exist. Now turn them into a knife and visit the Excel team.
Admin
Not exact a WTF, but comments are supposed to explain and help maintain the code. A little snark is acceptable, even desirable when it explains a workaround; devoting the space to venting your general opinions of the software involved is not. Imaging if there were a million lines of code, all commented to death like this. Almost as annoying as Excel.
Admin
I've got a query that stores two sets of related data in different fields (name/surname and alias name/alias surname if you like). If an alias is present, I want to use that, otherwise I want to use the real name. I was using NVL, but ran into some problems:
Unfortunately, alias_name can be nnull even when the surname is present (and I don't really want to concatenate them, because that will cause problems in the calling program.
Could you please assist?
Cheers.
Admin
I heard on the grape vine that Apple migth actually allow telephony from one of its future phones
Admin
Paul's not wrong. This is why I stopped doing any sort of Microsoft development when they pulled the calendar control out of Access 2003.
What. The. Fuck. Microsoft?
Admin
He's probably a nodejs programmer reading vb for the first time.
Admin
He's probably a nodejs programmer reading vb for the first time.
Ps: weird shit missing quotation forced double posts.
Admin
There's a lot of comments here that this isn't a WTF. It is, and here's why:
First of all, comments aren't for voicing your opinions, they should be concise, and to the point.
Second, if the dev was aware of commonly used C# commands, he wouldn't have had to leave that comment at all:
var sheetName = SheetName.EndsWith("$") ? SheetName : SheetName + "$"; cmd.CommandText = "select * from [" + sheetName + "]";
The above code clearly indicates that the additional '$' is only added of the sheet name doesn't already end with one. Job done.
Admin
THIS^
(Damn you akismet)
Admin
You guys are familiar with Apache's POI libs, right? They seem to have a similar attitude toward's Microsoft's file formats. :)
http://en.wikipedia.org/wiki/Apache_POI
POI - Poor Obfuscation Implementation
POIFS (Poor Obfuscation Implementation File System) – This component reads and writes Microsoft's OLE 2 Compound document format.
HSSF (Horrible SpreadSheet Format) – reads and writes Microsoft Excel (XLS) format files.
HPSF (Horrible Property Set Format) – reads "Document Summary" information from Microsoft Office files.
HWPF (Horrible Word Processor Format) – aims to read and write Microsoft Word 97 (DOC) format files.
HSLF (Horrible Slide Layout Format) – a pure Java implementation for Microsoft PowerPoint files.
HDGF (Horrible DiaGram Format) – an initial pure Java implementation for Microsoft Visio binary files.
HPBF (Horrible PuBlisher Format) – a pure Java implementation for Microsoft Publisher files.
HSMF (Horrible Stupid Mail Format– a pure Java implementation for Microsoft Outlook MSG files.
DDF (Dreadful Drawing Format) – a package for decoding the Microsoft Office Drawing format.
Admin
Butchers postal codes... you have got to be kidding. You are putting in postal codes as numbers and expect the program to somehow know the the leading 0 character is significant? That is really ignorant.
Dates of any kind. I am guessing that there is at one kind you know little about. What the hell are you talking about!?
... and similarly for the rest. I really think that most of the people who rant about Microsoft are pea-brained idiots. They apparently can't spend 2 minutes thinking about the complexity of the problems that a program like Excel is trying to solve. And the fact that for 99.9% of users it works wonderfully is a stunning achievement in a world where such a significant portion of the population are ignorant, self-important blowhards like most of the commenters on this thread. I have written a ton of code that interacts with Office: COM, .Net, even barbaric DDE stuff back in the day. I won't deny that the object model is complex. But every single time I had a problem like the guy where the 2003-to-2007 upgrade broke his function silently, there was some stupid mistake in the calling code that was actually to blame.
My vote for the RWTF: using OleDB to talk to a spreadsheet.
Admin
I don't code, but I do make the odd manual/ help sheet for end users and I always try to put in a little brief WHY in instructions; if you don't someone will think that the step is unnecessary. I like shortcuts and promote them when I can; they are part of being human. Justification dampens doubt.
Admin
TRWTF is concatenating strings with the "+" operator.
Nothing wrong with the use of var.
Admin
butcher's gone postal about the code?
Admin
That's the kind of comment I put in code sometimes; when you've been banging your head against the desk for the best part of day trying to figure out why something doesn't work, only to find that it's because of some bizarre piece of esoterica, that possibly had some logically explanation but you have no idea what it is, sarcasm and bile is often the way to go.
Also they're comments - they don't hurt the code and sometimes a little back story helps explain why this method that seems stupid exists. And if the way they're written gives a future developer a reason to smile, then so much the better.
Admin
To those of you who say that Paul is right, and that there's no WTF here: Well yes.
But I worry that anyone who feels the need to write that much over such a small issue is taking it very personally. He needs to take time out to read Eckhart Tolle, and to remember that this is his job and what he gets paid for. If it was easy, then everyone would be doing it and he'd be on the dole. Relax. Enjoy. Comments are good, but ranting is sad.
Admin
Any programmer who looks at that line of code and thinks what you have quoted deserves to be taken out and shot (or at the very least given a few lessons in mental unit testing with snoofle's cluebat)...