- 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
care-bear obliterates the competition by care-bear-staring into frist
Admin
WTFCommentA
Admin
WTFCommentB
Admin
Was this WTF generated via a WTF Generator, or did this really happen?
Admin
This is pure brilliant because...uh, never mind.
Admin
Gotta be fun to try this with unicode.
Admin
This is best practice on embedded devices!
Admin
I would take a photo of the alphabet on a wooden table...
Admin
This would've been even more brillant if written in VB.
Admin
(Java)
Admin
This is very handy.
Just in case the alphabet changes, in that case you are prepared!
Admin
That's actually pretty clever, in this way one can use inheritance to, I don't know, change the string associated to each letter. But it'd be better to dynamically generate this code through a SQL query, and embed the query into a PHP script. Then I'd write a small VB script piloting the cursor and the keyboard buffer in order to open Access, write the SQL query and launch it automatically.
CAPTCHA: dolor - how oddly appropriate.
Admin
This solution is clearly not correct. There's no support for lower case letters...
Admin
Wait....
Let me get this straight.
Everything in string the class is private and there are no other classes or methods?
I'm going to say it's the lack of sleep, but is there a point to this class if it's all private w/o getters?
Admin
This is ridiculous. It's utterly useless; how do you do lowercase letters? And punctuation?
Admin
-1: Where's the XML?
Admin
Генерация кода может быть эффективным инструментом для сильно вводе пользовательских доменов, если данный домен ограничена определенным набором ценностей. Приемлемые примеров можно назвать имена цветов, статусов, и штаты США, среди ряда других.
В некоторых случаях это полностью избыточными для этого, например, если вы сильно набрав алфавиту:
ClassTypeLetters общественного класса ( частных пд ClassTypeA = ""; частных пд ClassTypeB = "B"; частных пд ClassTypeC = "C"; частных строку сопзЬ ClassTypeD = "D"; частных ClassTypeE строку сопзЬ = "E"; частных пд ClassTypeF = "F"; частных ClassTypeG строку сопзЬ = "G"; / / H-W ... частных пд ClassTypeX = "X"; частных ClassTypeY строку сопзЬ = "Y"; частных пд ClassTypeZ = "Z"; )
Admin
ClassTypeLetters.CreateLetterTransformationFactory<ClassTypeA>(this).TransformLetter(LetterTransformationFactoryTypes.LowerCaseInvariant);
Admin
Are you implying that there WOULD be a point to this class if it was public and had getters?
Admin
private const string ClassTypeComment = "Comment";
Admin
Hah, love it. Actually I remember some legacy code I worked on right out of college that had the following C #defines:
#define ZERO 0 #define ONE 1
Glad we're isolated in case zero or one change their numeric values...
Admin
TRWTF is that the strings aren't marked static and final.
(Yes.... that will do.)
Admin
Code review: add classTypeComma, classTypeSpace and classTypeExclamationMark and you're onto a winner (a space and 2 punctuation marks ought to be enough for anyone).
Admin
#include <stdio.h>
#define LETTER_TABLE
X(A, "A")
X(B, "B")
X(C, "C")
X(D, "D")
X(E, "E")
X(F, "F")
X(G, "G")
X(X, "X")
X(Y, "Y")
X(Z, "Z")
#define X(a, b) a, enum LETTER { LETTER_TABLE }; #undef X
#define X(a, b) b, char *letter_name[] = { LETTER_TABLE }; #undef X
int main() { enum LETTER x = A; printf("x=%s\n", letter_name[x]); return 0; }
Admin
Bah, XML is for sissies: much better to use RSS for adding comments to the sourcecode, giving for each line of the code a different URL containing the documentation associated to it.
Admin
What language has both const and final keywords?
Admin
I couldn't said it better.
Admin
Actually, with the right approach, this could be a great idea.
Admin
Doxygen?
Admin
Oh, sure, get all technical on me...
All I can say is someone mentioned Java and then I blanked on the const....
Admin
Duh, just call .ToLower() to get lowercase. There's no need to reimplement functionality that's already provided.
Admin
You genius. How do comments get 'featured'?
Admin
Þat is a good point. Just add on:
private const string ClassTypeÞ = "Þ";
and þe code will be ready!
(I sure hope the Daily WTF comment software accepts thorns or this post will look stupid. Well, more stupid than it is inherently.)
Admin
I just threw up a little in my mouth.
Admin
It could have a purpose as part of a character classification algorithm or converting UNICODE/LATIN-1 to ASCII 7-bit say in e-mail or news readers.
E.g.
A a À Á Â Ã Ä Å Æ à á â ã ä å æ => ClassTypeA
Thinking really way out there, ClassType* could be redefined later on as Morse code or something and then it would be almost a logical way to do things.
ClassTypeA = DOT DASH; ClassTypeB = DASH DOT DOT DOT; ...
During development would set it first as "A", "B", etc. to make it easier.
Admin
Off-topic, I've come across code where the multiplication factors for k (as in kilo), c (as in centi), m (as in milli), ..., were defined in an XML file. This file was then parsed by the framework, whence a factory pattern was used to provide the required real multiplying factor to the end application.
This might have been an acceptable solution had the XML file been stored in a database table [n.b. the previous sentence is intended to be an ironical remark]. However, the XML was instead stored in the flash RAM of the embedded device, making it way too "hands-on" to be "enterprisey".
Needless to say, this "solution" was soonish returned to the designers for re-consideration.
Admin
Admin
Admin
I've seen something similar but with numeric constants. It was because corporate policy involved running a code style checker, and it complained about "magic numbers." Which really translated to "any numeric constant that was greater than 3."
Solution?
public class Numbers { public static int NUMBER_4 = 4; public static int NUMBER_5 = 5; .... }
Admin
Lucky you it was "college code"
I saw the following C defines in code at WORK, that runs on a embedded system which manage the communication module of a TRAIN.
#define THOUSAND 1000 #define THIRTY 30
and a few others.
I'm not kidding.
Admin
Lucky you it was "college code"
I saw the following C defines in code at WORK, that runs on a embedded system which manage the communication module of a TRAIN.
#define THOUSAND 1000 #define THIRTY 30
and a few others.
I'm not kidding.
Admin
Someone please explain to me how "Code generation" has anything to do with this particular WTF.
Admin
Well it could be worse.
#define ZERO 1 #define ONE 0
Admin
Admin
Admin
Admin
This sort of thing is not uncommon. The usual culprit is a "no magic numbers" clause in a coding standard (along with an implicit "no common sense either") of course ....
Admin
When you have a loop stating
for (i=0;i<7;i++) { /* do something */ }
you'll be guessing what 7 means and why the number 7 was used. Whereas if the same code would (depending on the language you use) would say something like
const DAYSPERWEEK=7;
then the loop would be
for (i=0; i<DAYSPERWEEK; i++) { /* do something */ }
...and this would make it instantly clear that the loop iterates each weekday (rather than the seven dwarfs in "Snow White").
Note also that your NUMBER_4, NUMBER_5, NUMBER_6 etc. do not add anything useful to the readability of the code.
Admin
Please, avoid any job that has a remote connection to localization or international communications. This algorithm is already used much to often. Under no conceiveable circumstances is "A" a good representation for an "Ä" or "Æ". If you really have to use 7-bit ASCII, Ä and Æ can be represented as AE. Not that there is a good reason for using anything other than a proper unicode encoding like UTF-8 anyways.
Admin
I'm all for strong typing. I make good use of YesNoUnknown (though had I rolled my own it would have been YesNoUnknownFileNotFound)