- 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
I love the // Without any comment.
They probably figured that they didn't want to over comment the code.
Admin
I especially love the lack of else if or else in the checking of the FieldName. It teaches your application discipline if it has to rigorously check all possibilities even when it already found the correct one.
Admin
<FONT face=Georgia>Wait a minute! You don't have to save data to a text file to share it with another function?[:'(]</FONT>
Admin
Wow....I don't know what else to say - this is a great WTF.
My little nit-pick of the code: concatenating values to a string instead of using a StringBuilder....ACK!
Admin
Well, you never know when it might change on ya mid-loop. [:P]
Admin
Wait, the text originally said
Admin
Oops, forgot to quote. This was in reply to Mike B.
Admin
"It's gotta be a relief for our dear friend Nikolay Simeonov to scream "WTF" at today's example of how coupling. "
"And no, the printing function wasn't taken from another system, nor was done so but another reason - it was just the only way to send information between different functions, which this lady found out for the moment."
You have to love a site where people who can't write a complete sentence in English make fun of the way people write code.
Admin
Code != English
Guessing by the name, I'd say the guy submitting this was a non-native English speaker.
Simon
Admin
It's called "Maintaining a programming site at 3 o'clock in the morning".
====================
This code suddenly made me miss the days of "LPrint" and "echo LPT1"
Admin
If we're going to be picky, it's not just the comma that should be changed -- the "which" should be changed to a "that."
", which..." adds extra information (which, by the way,...)
"that... " adds identifying information (which one? the one that...)
There's a fancy name for the difference, but my English-geekdom is failing me at the moment, so I'll just have to let the above parentheticals do the explaining.
Admin
Actually you are wrong. I got the following straight from a rather good English teacher (and I've seen it in books as well).
The person who is working.
The car which is stopping.
"That" can be used in place of "who" or "which" but those two are the "original" words. "That" is just used for convenience.
Admin
Reminds me of my boss of my previous work.
He wanted me, to adapt the existing print/mail dll to create files on the server and print them when necessary, instead of adapting the dll to check the db, and get the data; when necessary. (A lot of files needed creation, so you would need a lot of storage capacity and you'd have a little redundancy off course.)[:|]
I think you needed to see it in order to get the impact of the story [;)]
Admin
If the function happens to be called twice in the same second then BOOM
Drak
Admin
Who decided the English teacher is good? In which books have you read it?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
You cannot replace 'who' with 'that' in the following sentence: <o:p></o:p>
'My father, who left Berlin last night, will shortly arrive'<o:p></o:p>
The issue would appear to be more complicated than you think.
In formal writing 'that' is used where the clause is essential to the sentence, ‘which’, and commas, is used where the clause can be removed without changing the meaning of the sentence.<o:p></o:p>
The first meeting that he needs to attend is on Monday.<o:p></o:p>
Her report, which was handwritten instead of typed, was a week late.
In this forum, though, it hardly matters which is used, especially when the author isn’t an English speaker.<o:p></o:p>
Admin
Hey, great way to treat your employeess [sic] Nikolay! Sitting around looking to make fun of their mistakes... That's real the WTF!!! That and your English usage.
Admin
Is it just me or is this thread turning into an online English class?
Admin
Putting print data into a file before acually printing it is not uncommon, escpecially in the unix world.
After all, what do you think the print spooler will do with the print data? Right: put it into a temp file.
Having a text file with the print data also makes it easy to check it before printing (especially during development and testing) or to use other means of transmission, e.g. email, file import into an other program etc.
The foreach(Gridcolum...) loop seems ridiculous, but it would make sense if the user can rearrange the columns of the grid.
Using a monospaced font is the easiest way to do it. There are ways to make it more pretty, but they actually require more work. Constant width preformated text is the most universal format.
Admin
<font size="2">I'm guessing you were joking, but I have recently been reading about concurrent programming -- which, with the advent of commodity multicore processors will be much more common into the future -- where this sort of thing is a real consideration.
</font>
Admin
<font size="2">
With regard to the code: I note that it is written in C#, so this must be a relatively recent thing. Usually I think of these examples as snippets emerging from code that is decades old, where the original programmer is out of reach for purposes of direct mockery and, more importantly, education.
If the (poorly named) Printing() function just prints the given file (without explititly opening it and reading it) then this set-up would make some sense -- you use the generic file-printing function and leave behind a timestamped snapshot of the print-out on your hard drive.
Nevertheless, the function is poorly constructed. However, instead of scurrying off to post this on a website so other people can mock it, you should go and speak to the author to explain the pitfalls of their logic and to suggest better ways of implementing this functionality.
It is hardly fair to mock someone behind their back if you haven't given them a chance to improve -- I'm inclined to think that the programmer meant well, but just didn't know better; and we all have to learn sometime.
If this programmer is within your "reach", I'd be inerested to hear how you get along in trying to pursuade them to think about the design and to re-implement their function; or at least point out that the implementation was poor, and explain your reasoning in a way that they understand.
We all have to learn from our mistakes, but if no one tells us when we make mistakes then it becomes quite hard.
(Unfortunately, there is the possibility that, when confronted, this programmer will blow off your suggestions and refuse to even think about what you're saying -- this would be inexcusible and you should then push to have them redeployed in a non-programmer position, or dismissed from the company alltogether.)
Happy Coding,
asqui</font>
Admin
Using which instead of that is correct in UK English. In American English only the version with the comma is correct.
Admin
Some years ago, I've seen (and changed) a much worse example of "loonily coupling", also in a report printing program. This program consisted of two parts: one read the necessary data from the database and created a ".ini"-style file which contained all data on a field per field basis.
The other program merged this ".ini"-file with templates.
Because of the "straight-forward" programming style of the second program, it's efficiency was o(n^2) - so while small files were printed quickly, big files blocked the system for up to 5 minutes!
Admin
And your english is perfectly flawless Mr. Anonymous Coward? [li]
Admin
This is actually my favorite part:
fileName = "C:/QueryReport/"
I just plain dig it when people get their slashes mixed up.
Admin
Blimey, what happened to the thread today? Is there an ex-English teach with a grudge?
Well I ain't having none of it.
:-)
Admin
Blimey, what happened to the thread today? Is there an ex-English teach with a grudge?
Well I ain't having none of it.
:-)
Admin
Jesus, Anonymous Coward shows up everywhere I go. Slashdot, www.c-evo.org, and now here. Though with his voluminous posts on slashdot, I wonder if he's unemployed software engineer.
Admin
And yes I'm only kidding... though I find it surprising that people willfully call themselves Anonymous Coward.
Admin
It is of-course perfectly valid in terms of slash direction on NT based systems (definately 2k & XP) - given this looks like MS's take on C++ or Java then perhaps the writer didn't understand about escape characters ? Although I'd have to critisise other aspects, such as using fixed directory names and that kind of thing.
Admin
So if you were on my place you would be happy to see this done by someone, working for you?
And isn't this site about code, that makes you say WTF when you see it?
I am really sorry about my English and the fact it upset all the people on the forum. I know it isn't perfect, but unless you know at least <FONT color=#000000>one </FONT>language other than English and you can speak/write as good as your mother language, please feel free to correct me. (Just for the record - I know 2 foreign languages - not perfect, but I can understand others, they can understand me... It's ok for me to get my job done.)
Admin
See, you'd think I would have caught both my mistake and yours before posting ... man, I have poor proofing skills.
Admin
This is the piece, making me scream WTF. Thy loop through the columns at all, comparing the name to apply proper formatting? Why not just concatenate the values of the neccessary columns one after the other and voila - the report is done.
Admin
you mean throwing the data just to read it again from another function?
How much of this are you ready to accept? What about 6 months seeing stuff like this, explaining how to do things and still seeing similar stuff all around? Asking her WHY did you do that, there was no answer (or it was - because this was the first thing, that occurred to my mind). She's gone for about a year now, all the code she wrote I basically thew on the garbage and did it all over again.
Absolutely agree with you... but everyone's patience has a limit. And in every piece of code from this lady you will see portions making you say loud WTF. This was one of the masterpieces so I thought I would share it.... after all I paid for it, didn't I? She was getting salary for about a year, wasted my time, screwed up 2 projects, pissed off the customers... are you getting the picture?
By explaining how to improve it, examples from other code, written by me, etc. When it goes about software coming from my company it should be as good as I wrote it myself or at least close, not garbage like this.
Man, I was spending hours teaching her and explaining what's wrong, why it's wrong and how should it be. However I was seeing more and more of this crap. Re-assigning to another position was out of question - she was refusing onsite customer support and since my company isn't really huge I cannot afford wasting resources and especially my time. After all I was trying to teach her for over 6 months - it's a real job not school.
Admin
I wonder why these people get so upset about the grammar. I know people from New York with terrible spelling, what to say about their grammar and unless they use a spelling checker you can hardly understand what they typed. No joke.
Admin
"Commas", which trim the fat
Begin with "Which"
And never with "That"
Admin
The best pseudonym I ever found on a chat room was "Annoying Rectal Itch". He was a treat.
Admin
In C/C++ it's perfectly valid on Win9x too, for portability reasons.
Anyway the whole issue seems nitpicking to me. There could be 10000 other reasons for using a file, like, for example, keeping an history of prints, reusing old code (which the poster of this wtf didn't know about - what if the author of the code simply had that printing function on her pen drive written 3 years ago ?), easier debug, compatibility with other printers, ability to recover an old report and reprint it, direct compatibility with PCL printers, etc. etc. etc.
It could even be because the programmer had only 30 minutes available to write that code, and this probably was her fastest way to implement that [the constant output path is usually a sign of not enough time for implementation].
Admin
Well, I was just saying that if you already have a PrintFile() and you want to have an archive of the reports that were printed, then generating the file and calling PrintFile() on it would be acceptable.
It was just speculation, and probably not applicable in this example. (Certainly not if your PrintFile() explicitly opens and reads the file itself.)
Sounds like you hired a dud. Bad luck.
At the moment I'm finishing off a re-work of some marvellous crap that a predecessor of mine created... this was truly cringe-worthy and I might even post some of it here if I have time later. Suffice to say that I've pretty much re-built it from the ground up because what was there before was so unreliable and un-readable.
I feel your pain.
Though, to be fair, if you hired her as a programmer (as opposed to, say, an apprentice) and she was producing drivel like this then you should have dismissed her much sooner. ie. Almost immediately.
Agreed.
A real job indeed... how did you come to hire (and retain) her as a programmer if her skills were so poor?
Admin
There are other ways? [*-)]
OK, this is my second post, so you probably don't realize I'm joking. I use a temp table and stream this stuff into a BLOB field in another database that I create on the fly. If I need to store more information, I just add another table/field combination to the database. Someone suggested that I should just another field to the first table. I haven't tried that yet. Is that easier? It looked pretty easy in "A Database's Database"
I'm learning so much with these great code examples. Keep them coming!
Admin
Because she made me think she knows more and then I didn't want to fire her immediately before giving her a chance to do something for real. I was hoping, that she will learn from her mistakes and after a short while she will be capable of writing real code without a lot of help. After all there are so many books around and an incredible amount of online information... We have google to search for examples, many newsgroups and forums to get some help - even if you're an absolute beginner. And by all means not knowing how to do something doesn't mean you should do the first thing, that occurs to your mind, does it? It isn't a shame to ask, it's a shame to write code like this... agreed?
Admin
If the user can change the order of the columns, and he wants the columns in the report printed in the same order, the foreach loop might be a valid solution.
Admin
... lately I heard there are report building tools allowing you to print a header, some logos and they actually have some designers built in.
That was black humor... Actually my company is using some third party report tools from ages. Crystal Reports could be another good choice (compared to this file-s**t) and it comes with Visual Studio and isn't bad either, although it adds too much overhead IMO.
Also you're not right about the column order. In this particular case we use XtraGrid and the columns have a property called VisibleIndex, so the original order is kept no matter how you're re-arranging them.
Admin
I'd say the problem here is that the system may not have C: drive at all, not slash direction which is by the way valid since w2k.
Admin
I was of course referring to this:
Admin
don't these people know how to use a case? duh
switch($apok) { /** etc... */ }
Admin
Yes. The articles show us how not to code and the messages show us how not to write.
Admin
This program looked to be written in C#. The .NET CLR accepts file paths with slashes going either way, case-insensitive.
The real wtf is that windows local directories are supposed to start with a lowercase letter!
Admin
Forward slash worked in MS-DOS 3.3, maybe even earlier too....
Admin
Passing arguments between functions, using a temp file ? Now thats a global if I ever seen one.
Admin
The REAL wtf here is that System.IO.Path.PathSeparator wasn't used! lol ;-)