- 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
Personally I don't like that (ever seen ASM code with french identifiers?), though I don't mind it in smaller programs, eg. in "Var Datei : File;"
And my version of Paul's example would be:
falls (Bedingung)
// irgendwas
ansonsten (Bedingung2)
// irgendwas anderes
ende
Admin
Even if you know English very well, it is often not practicable to name everything in English. If your specifications are in a different language, you do NOT want to translate every domain-specific term so that the developer has to know that when the analysts and end users say "Schuldverschreibung", he has to look in the code for "debenture".
Admin
sigh
Admin
However in Perl ...
See http://www.csse.monash.edu.au/~damian/papers/HTML/Perligata.html
Admin
I've occasionally seen this syntax for pseudocode. And it is used by spreadsheed applications for the formulas.
Admin
I generally think that comments are often over- and misused and then more hindrance than help, but discouraging comments in general is going a bit too far. Then again, if the exception "code that cannot be made self-explanatory" is interpreted right, it probably covers everything where comments are actually useful.
On second thought, I like this policy!
I HATE comments that repeat things that are obvious. They are not only useless, they actually decrease code clarity by distracting from the code and taking up space. And the worst thing is that the same people who comment
index++; // increase index by one
are very often those who totally fail to comment stuff that is non-obvious and non-local, such as what a class or method is actually used for and what its name means.
Comments exist to help other people understand your code. NOT to give you a warm, fuzzy feeling about being a good little programmer with a high comment/code ratio.
Admin
Well I certainly agree with that. When I said that i like to comment stuff even though they might be self-explanatory i mean that I like insert comment explaining the use/interface of
every function, class, global, constant, even though it's purpose might be fairly obvious, E.g.
(note, this from a
/*
* @global array an associative array runtime configuration parameters are stored.
*/
$Configuration = array()
Damn, 'cause it's that feelin' o'rigeousness that keeps me dilligently commenting. ;-)
Admin
// No comment.
Admin
That sounds like something the Quebec government would love to invest billions into
Yeah, but only as long as they are part of Canada, in order to prove Ottawa wastes billions sending money to Quebec to finance such a law. If they separate, it's another story...
Admin
Aleph is about as silent as K is - sometimes, sure, but generally it isn't. I wonder if his Japanese is as bad (but not enough to actually go check it on Wikipedia).
(Actually, aleph would never be silent at the beginning of a word, but you know what I meant.)
Admin
I like comments like this.
They are correct, and let me know what the mindset of the developer was. They are mostly useless, but it doesn't take long to read them. In the back of my mind I can retain the knowledge of what 'gaiden' is, and thus every time I see that function from then on, I know what it is doing.
The second is useful - it identifies something I don't know - what language to translate comments from. Without it I'd might try a Catalin->English translator first. (I have a soft spot in my heart for the beautiful areas where Catalin is spoken, even though I don't speak it myself, so I'd try that language first when I see a Latin alphabet with a language I don't recognize.)
Where comments are not needed there should be no comments. Where comments are needed there should be comments. These comments are needed - the first explains a strange choice of names, while the second tells me how to deal with the rest of the code.
Though I would agree with anyone who notes that both comments would be unneeded if the rest of the code was done better in the first place. But given the typical code out there, comments like this are important.
Admin
System.String TextToOutput = "";
if (CommentsNeeded)
{
TextToOutput += "Please Add Comments!";
while (CommentsNeeded)
{
foreach (string LineOfCode in EntireCodebase)
{
TextToOutput += "\n";
TextToOutput += ExplainWhy(LineOfCode);
}
}
}
else
{
TextToOutput += "DO NOT ADD COMMENTS!";
}
System.Console.Write(TextToOutput);
Admin
eh, I didn't debug my pseudo code
Admin
Just to clarify... Is it a bad idea to use those identifiers, or is PL/SQL just a bad idea in and of itself?
Here here! Well spoken, Bruce!
Admin
I see potential problems with these two.
Sincerely,
Gene Wirchenko
Admin
Perl does support UTF-8 characters in variable names, as long as the use utf8; pragma has been included in the source code file. And, as someone between your post and mine has linked to, there's the Lingua::Romana::Perligata module for programming Perl in Latin.
Admin
They must have skipped assonance and alliteration in language arts.
Admin
It's definitely a bad idea to use accented letters in PL/SQL for a simple reason: after exporting and importing them with the oracle tools "exp" and "imp", accented letters will be replaced with their non-accented (US7ASCII) versions. Maybe not always, but often enough.
In many cases, this alone will not immediately break the program, because the definition of an identifier and all references are silently changed at the same time. But it is a time bomb, because sometimes later, you try to install a new version of the program from a script that still contains the accented letters to install a new version and BANG it breaks at dozens of places.
About PL/SQL being "a bad idea in of itself", let's say at other database do worse (TSQL etc.)
In the company I work with, we write lots of code in PL/SQL (read: all the business logic), and it works pretty well for us, with typically 20-50 concurrent users, ~200 users at most.
But of course PL/SQL has its limits; I have seen projects that tried to do things with PL/SQL it definitely was not build for, like parsing complex templates (they made a CMS completely within
the PL/SQL cardridge of the OAS), and although it worked (kind of), it was sluggish despite all
the expensive hardware thrown at it.
Admin
Quebec can't separate! If they do, Newfoundland would float away!
Admin
I've actually done substantial amounts of PL/SQL. I spent about 5 years as a PL/SQL developer and I'm still not sure whether or not I like the language. :)
Although, PL/SQL did seem to be a dream like language after writing step triggers for Oracle Forms 2.3. Now THAT is a WTF.
One of my proudest accomplishments was porting an encryption routine from C to PL/SQL. Encryption is extra-fun when you don't have bit manipulators. I was prepped for that one a bit by first porting the same routine into PowerBuilder in a prior project.
Admin
GaidenCommander? Um, did they also have a class BattlecruiserStrikeDecimatorPlus or something? Did the naming conventions include "All class names must sound like attacks performed by anime characters"?
Comments in non-native language are fun. In a project I worked on, a fellow programmer added (in Finnish) a helpful comment next to a hideous temporary hack: "the implementors of this function are highly skilled professionals of the field, and complete idiots. Dear kids, please don't try this at home." The manager did understand the humor, but the first comment from them was that the comments were supposed to be in English...
Admin
For another take on this:
http://sluggy.com/daily.php?date=051126
Snigger!
Sincerely,
Gene Wirchenko
Admin
You were actually exposed to the idocy of trigger steps? I feel sorry for you... I was more lucky,
three times I managed to escape from Forms 2 and my first SQL*Forms project was already with version 3 and PL/SQL. The biggest WTF in Oracle Forms was about COMMIT; too bad I don't have the code of that old Forms3 project, where almost every form had a block referencing the DUMMY table, so a commit could be performed; it would be a nice WTF for this site.
(For you non-Oracle-aggrieved guys: in Forms, fields are organised in blocks; every block can be bound to a database table, so that changes in the fields (by the user or programmatically) automatically cause corresponding update/insert/delete statements on the table. Forms does (in all versions I know) not perform a commit unless at least one insert/update/delete is performed that way. Too bad if you want to encapsulate all update statements in PL/SQL blocks...)
That's what they told us about the Turing machine; if it can be programmed at all, it can be programmed in any turing-complete language.
Admin
I was the technical lead on a project taking an internally developed financial system from DOS-Forms 2.3-SQLNET 1-DECNET to Win95-Forms 4.5-SQLNET 2-TCP/IP. We off-shored the conversion of the forms to a company that promised they could do an automatic conversion. Apparently they had a tool to do conversion to Forms 3.0, then another tool that would convert to Forms 4.5. By the time it was done, the code was a mess of 'goto's, but we got it working in time for Y2K.
DECNET had a nice utility that allowed you to execute a command on another server, connecting the standard in/out/err streams to the local process across the network. I don't remember the details, but nothing we found in the standard TCP/IP based stack worked quite the same way. I wound up writing a utility that would create a DCL (VMS shell language) script, ftp it to the host, rexec it, and ftp the result back to the client. It was a big WTF, but I was able to isolate it into a library so noone else needed to see it.
Admin
I once knew a guy who had actually worked on translating Japanese console games for the US market. The text he had to translate did NOT come in nice, separate resource files, it was embedded in the code. And he was also supposed to translate the comments in the code (which were all Japanese) so that the coders of the US licensee would have an easier time of making modifications.
In one game, he found a comment at the top of a file that said "Hi, I'm $NAME, I'm a programmer here, and I'll write my comments in Kansai dialect" - of course in strongly Kansai-accented Japanese.
It had me in stitches, though I guess it's not half as funny if you don't understand Japanese and can recognize the dialect.
Admin
Please inform him that Aleph is NOT a silent letter, unless I have been misspelling my first name for the past 30 years.
Why do I feel he will still argue ?
Admin
If the comments are not updated as the code evolves, are the "self-documenting" function and variable names going to be updated any more often? I've seen plenty of examples where the latter reflect the original, rather than the current meaning. At least comments are easier to change - you only need to change them locally, not everywhere the identifier is referenced.
Admin
As the submitter of the second comment (which comes from some code in my previous company that actually originated from another company), I would like to mention that there weren't much in the way of comments in the code anyway, and that they were badly spelled, had bad grammar, and sometimes barely made any sense at all.
By the way, I'm french and even when I was working for french companies, I was always writing my comments in english. One french company I worked for actually demanded that, just in case they would need to get foreign subcontractors to work on the code at a later point, which IMO is a sound decision.
By contrast, the company from which the second comment originates is a france-based international company, with development going on in several places in the world, so writing french comments was really stupid :)
Anyway, most of the programming material you find on the net is in english, so any programmer who can't be bothered with english is a crippled one imo.
Admin
IsTrue
[pi]
Admin
This is only partially true; because although every programmer must understand English words like "class", "loop" or "statement", there may be many domain-specific words which are not readily understood in English, only in the native language.
Admin
Well, not being English, I could feel sorry for the native English speakers having to deal with all those English computer words that actually have a meaning in non-computer life as well! Isn't it quite odd to use the name "Windows" while using the very same word for, errrr, windows? Browser? The home and escape key? Directory? A set-top box? Oracle? Doesn't the missing R in RFC 1945's Referer bother you?
And above all:
Hello World? ;-)
Admin
*shudder* sounds like excel.
never got the hang on iif,though..
Admin
I'm the author of the first comment, the GaidenCommand one. Just a minor few points:
- The GaidenCommand is a private, implementation dependent, inner class for a more reasonably named class called the "CommandManager."
- The poster also conviently deleted the comments explaining what the class does. Makes for a better WTF : ) I'l repost the entire comment here:
///
/// The GaidenCommand is a specialized Command for use by the
/// CommandManager. The GaidenCommand is directly hooked up to some UI
/// object, and when that UI object is triggered, it triggers the
/// GaidenCommand.
///
/// The GaidenCommand contains a regular, user-supplied Command. As
/// described above, when the GaidenCommand is triggered, it will
/// execute the user-supplied Command (if it has one).
///
/// Note, the word "gaiden" is Japanese and means "side story",
/// see "http://en.wikipedia.org/wiki/Gaiden".
/// Why did I call this "GaidenCommand"? Because it's very similar to
/// a regular Command, but it serves the CommandManager in a different
/// way, and it is not the same as a regular "Command". Also
/// "CommandManagerCommand" is far too long to write. I also toyed with
/// calling this the "AlephCommand", Aleph being a silent Hebrew
/// letter, but Gaiden sounded better.
///
private sealed class GaidenCommand : ICommand { ... }
Why did I name it Gaiden? Because I was hard pressed to think of something more appropriate.
I thank the poster for not coming by and suggesting a better name, and trying to nail me on a naming issue versus the quality of the design behind it.
ARKBAN
Admin
I'm newly learning Hebrew, and in Hebrew the aleph is a silent letter. If it has a vowel it has a sound, but by itself it has a sound. Please correct my if I'm wrong, as I said I'm new to Hebrew.
Admin
How about IndirectCommand. Or MetaCommand. Or CommandCommand (yes that's weird). I don't now the difference in functionality between a GaidenCommand and a Command, but I sure as hell bet that the difference between the functionalities of a GaidenCommand and a Command isn't a 'Side story'.
Admin
I decided the best approach was to throw the meaning as far from away as possible rather than create a lot of difficulty relearning or alterning an existing concept. (In truth I renamed the class at least 3 times with a thesaurus in hand trying to thing of something better). Trying to make one learn a subtly different definition of a word is much harder than learning a totally new word. The former you must unlearn what you learned, or at worst try to mentally keep track of two different concepts and figure out which applies and what are the subtle differences. It unfortunately goes against what a human brain is good at.
So rather than the reader going "Wait, I know what XXX means, but is this isn't XXX at all, where are the differences and commonalities" I took the approach of forcing the reader to say "WTF is this? I better read this over carefully (or go ask the guy who built it)." I guess you could argue it's an intentional WTF, to try and prevent the reader from improperly applying any (possibly invalid) assumptions (a mistake I've seen happen far too often).
I've yet to see a good solution for this sort of naming issue, and I include mine in that pile of bad solutions.
Also I want to mention that I always follow this sort of statement "I have commented just about everything; you should be able to figure it out without a problem." with "but come ask me any questions" and "if you see away to improve the comments and/or code, let me know how". The amount of out-of-context the submitter used is priceless.
I'm disappointed that it's not as difficult as I thought to trick the Daily WTF. But I guess that's my issue, I was gullible and believed that one would not intentionally manipulate code to make it worse than it was, or post it to Daily WTF without ever mention the issue or offering a better solution to the author.
ARKBAN
Admin
Come on, smile, learn from the comments people have posted and don't try to talk your way out of it by blaming this wonderful web site. This site is not about nailing people.
I really think that the full documentation you posted, in which you're repeating yourself but in my opinion really are not clarifying anything at all, only makes the WTF worse. And you even claim you've renamed the class at least three times -- then how much time did you spent on writing that comment and how much money did you make for that?
Agreed, it would have been nice if you would have received feedback. But the WTF is not about whether or not you're willing to spend even more time on the documentation. It is about the documentation you released, and which appearently you still think is well written. I agree with the one who submitted it as a WTF: I think it is useless, and a waste of time both for yourself and the one who's to maintain the code.
By the way: how could a "private, implementation dependent, inner class" be "directly hooked up to some UI object"? Truth or dare: please post the code that was following the submitted comment?
Arjan.
Admin
According to Terry Pratchett, it would have to be one of those million to one chances: bound to happen, but only if the odds are EXACTLY a milion to one!
Admin
Really? I always thought IIf was relatively simple, rather like the ternary ?: operator in C-ish languages... It helps that I read somewhere that IIf stood for (or could be interpreted as) "Immediate If", which is effectively what the ternary operator is...
IIf (a , b, c)
and
a ? b : c ;
are both compact representations of
which can be evaluated as an expression, and thusly used on the right hand side of an expression...
Admin
Well, it depends on which domain. Take computer science, for instance: most of the theory and stuff behind it originated from english-speaking countries, so most of the domain-specific terms are actually english, and most of them don't have any useful translations - at least in french (I don't know how it goes for other languages).
Of course, some books try to litteraly translate them, which makes for ridiculous and annoying results. The concept of template in C++, for instance, is known as template, even among french programmers.
In the french edition of stroustrup's book, they translated it into "modèle". So you then have to perform the mental gymnastic of translating it back to template.
Anyway, my point wasn't about the keywords used in the language, but rather about the availability of knowledge, articles, litterature, forums and so on in english compared to french.
Google may be the best programming tool around, if you can read and write english. It's not such a good tool if you can only search for information in, for instance, french.
Admin
stupid ass[:@]
lol
looser
loose
looooooooooooooooooooooooooooser
looooooooooooooooooooooooooooooooooser
looooooooooooooooooooooooooooooooooooooseer
loooooooooooooooooooooooooooooooooooooooooser
Admin
ARKBAN, you want feedback, here's mine:
1. you could have done withoug this.
/// Why did I call this "GaidenCommand"? Because it's very similar to
/// a regular Command, but it serves the CommandManager in a different
/// way, and it is not the same as a regular "Command". Also
/// "CommandManagerCommand" is far too long to write. I also toyed with
/// calling this the "AlephCommand", Aleph being a silent Hebrew
/// letter, but Gaiden sounded better.
I think this is the most 'wtf' part of the comment. Putting a "I" in there and spending 6 lines telling your story on why you choose the name ... I understand you spend time thinking about a name, but I don't really need to know what.
2. you could probably have done without this one too:
/// Note, the word "gaiden" is Japanese and means "side story",
/// see "http://en.wikipedia.org/wiki/Gaiden".
If you need to spend a large amount of time explaning a name (or a link to wikipedia), maybe it's not the best name possible. Frankly, I think something like CommandManagerCommand (or CMCmd) even if less aesteticly pleasing does the job done just fine.
my $.02. Peace.
Zorro.
Admin
Also,
/// "CommandManagerCommand" is far too long to write.
too long to write? Any modern code editor (windows IDE or unix vim/emacs) has name auto-completion. I'd trade a 'what does that mean' to a 'long to write'/'hit-autocompletion-key' name any day of the week.
Admin
I have to defend ARKBAN here. Obviously if he puts this much thought into choosing all of his identifiers, he's going to end up in the loony bin, but I'm assuming he doesn't. It sounds to me like he simply encountered an awkward naming problem that stumped him. Sure, his solution was in the end worse than the disease, but all of his extra commenting indicate to me he had sense to draw attention to the problem. A funny name with a comment could be very helpful to a reader as a marker of an unusal or novel pattern. 'CommandManagerCommand' is not really acceptable either. Again, I'm sure there are dozens of better solutions to this naming problem, but at least he was conscientious about it.
BTW, how the crap am I supposed to just add a new post to the thread? Why am I made to reply to an individual post?
Admin
Except that
IIf(f(a), g(b), h(c))
evaluates f(a), g(b) and h(c) whilef(a)?g(b):h(c)
evaluates either f(a) and g(b) or f(a) and h(c) (same thing for the if/then/else construct)