- 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
The real WTF is the lack of comments. A close second is the undescriptive variable names.
This function obviously has to deal with many special cases (probably as a result of a long line of WTFs) and there's really no elegant way to do it. Comments would make it understandable and maintainable.
Admin
forget all obfuscators. do it manually!
Admin
VB uses a windows system dll to do rounding. This has three unfortunate side effects:
Excel uses a dedicated math engine, and windows system programmers don't fool around with it. Also, for most people, Excel defines the 'correct' answer. (I don't know what kind of answer the C examples given here return: when I was doing that stuff C didn't have a standard math library)
The odd mixture of Switch and repeated IF statements indicates either that the programmer changed, or that the programmer has been learning on the job. But since the global excel object is fully described in the IF statements, but implied in the Switch statement, I'm betting that this is the product of more than one mind.
VB Switch statements are a powerful and flexible construct, added during the interpreted phase of the life of the language, but this Switch statement adds nothing to this code: it's just a coding style anomoly.
Admin
I made a function that had that many special cases once. Of course, this was back when I was in highschool and just getting into programming...
Admin
It looks like reverse engineered code: disassembled and lazily rewritten into basic, without the finishing touch of actually making it decent to read.
Admin
How can anyone dislike the function which goes "Beep"?