| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
care-bear obliterates the competition by care-bear-staring into frist
|
|
Was this WTF generated via a WTF Generator, or did this really happen?
|
|
This is pure brilliant because...uh, never mind.
|
|
Gotta be fun to try this with unicode.
|
|
This is best practice on embedded devices!
|
Re: ArticleTypeCodeSOD
2010-05-26 09:11
•
by
Barry
(unregistered)
|
I would take a photo of the alphabet on a wooden table... |
|
This would've been even more brillant if written in VB.
|
|
(Java)
|
|
This is very handy.
Just in case the alphabet changes, in that case you are prepared! |
|
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. |
|
This solution is clearly not correct. There's no support for lower case letters...
|
|
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? |
|
This is ridiculous. It's utterly useless; how do you do lowercase letters? And punctuation?
|
Re: ArticleTypeCodeSOD
2010-05-26 09:26
•
by
grizz
(unregistered)
|
-1: Where's the XML? |
|
Генерация кода может быть эффективным инструментом для сильно вводе пользовательских доменов, если данный домен ограничена определенным набором ценностей. Приемлемые примеров можно назвать имена цветов, статусов, и штаты США, среди ряда других.
В некоторых случаях это полностью избыточными для этого, например, если вы сильно набрав алфавиту: ClassTypeLetters общественного класса ( частных пд ClassTypeA = ""; частных пд ClassTypeB = "B"; частных пд ClassTypeC = "C"; частных строку сопзЬ ClassTypeD = "D"; частных ClassTypeE строку сопзЬ = "E"; частных пд ClassTypeF = "F"; частных ClassTypeG строку сопзЬ = "G"; / / H-W ... частных пд ClassTypeX = "X"; частных ClassTypeY строку сопзЬ = "Y"; частных пд ClassTypeZ = "Z"; ) |
Re: ArticleTypeCodeSOD
2010-05-26 09:28
•
by
Mister Zimbu
(unregistered)
|
ClassTypeLetters.CreateLetterTransformationFactory<ClassTypeA>(this).TransformLetter(LetterTransformationFactoryTypes.LowerCaseInvariant); |
Are you implying that there WOULD be a point to this class if it was public and had getters? |
|
private const string ClassTypeComment = "Comment";
|
|
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... |
|
TRWTF is that the strings aren't marked static and final.
(Yes.... that will do.) |
Re: ArticleTypeCodeSOD
2010-05-26 09:38
•
by
SR
(unregistered)
|
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). |
|
#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; } |
Re: ArticleTypeCodeSOD
2010-05-26 09:40
•
by
pointyhairedpeon
(unregistered)
|
|
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.
|
Re: ArticleTypeCodeSOD
2010-05-26 09:42
•
by
@SuppressWarnings
(unregistered)
|
|
What language has both const and final keywords?
|
I couldn't said it better. |
Actually, with the right approach, this could be a great idea. |
Re: ArticleTypeCodeSOD
2010-05-26 09:58
•
by
Keith Brawner
(unregistered)
|
|
Doxygen?
|
Oh, sure, get all technical on me... All I can say is someone mentioned Java and then I blanked on the const.... |
Duh, just call .ToLower() to get lowercase. There's no need to reimplement functionality that's already provided. |
Re: ArticleTypeCodeSOD
2010-05-26 10:09
•
by
Jim
(unregistered)
|
You genius. How do comments get 'featured'? |
Re: ArticleTypeCodeSOD
2010-05-26 10:15
•
by
Mr Smiþ
(unregistered)
|
Þ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.) |
I just threw up a little in my mouth. |
|
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. |
|
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. |
Re: ArticleTypeCodeSOD
2010-05-26 10:44
•
by
Kempeth
(unregistered)
|
I totally agree! As it is you have to change the source code every time the alphabet changes. |
|
|
|
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; .... } |
Re: ArticleTypeCodeSOD
2010-05-26 10:51
•
by
Salvatore
(unregistered)
|
|
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. |
Re: ArticleTypeCodeSOD
2010-05-26 10:52
•
by
Salvatore
(unregistered)
|
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. |
|
Someone please explain to me how "Code generation" has anything to do with this particular WTF.
|
Re: ArticleTypeCodeSOD
2010-05-26 11:07
•
by
Hatterson
(unregistered)
|
Well it *could* be worse. #define ZERO 1 #define ONE 0 |
+ ClassType1 |
Re: ArticleTypeCodeSOD
2010-05-26 11:24
•
by
AnOldRelic
(unregistered)
|
This kind of thing needs to broadcast DOT DOT DOT DASH DASH DASH DOT DOT DOT. |
Agreed. You obviously couldn't do that... |
Re: ArticleTypeCodeSOD
2010-05-26 11:44
•
by
tragomaskhalos
(unregistered)
|
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 .... |
Re: ArticleTypeCodeSOD
2010-05-26 11:46
•
by
Anonymous Coward
(unregistered)
|
Obviously you were the person they needed that code style checker for. Why 4? 5? 7? 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. |
Re: ArticleTypeCodeSOD
2010-05-26 11:48
•
by
getofmymetriclawn
(unregistered)
|
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. |
|
I'm all for strong typing. I make good use of YesNoUnknown (though had I rolled my own it would have been YesNoUnknownFileNotFound)
|
| « Prev | Page 1 | Page 2 | Page 3 | Next » |