| « Prev | Page 1 | Page 2 | Next » |
The earths rate of rotation changes on a regular basis so the joke's on you! [;)] |
|
:O Dude. W.T.F.F.
These look like the work of people who never understood the purpose of constants yet still somehow managed to remember their CS101 Prof's admonition that "literals in code are bad, use constants to define literals and use those in code." Thus, instead of meaningful constants such as SIZE_OF_HEADER or BUFFER_SIZE you get INT_512. |
|
You know, I was just checking about:config in my firefox, and I noticed general.config.obscure_value as well
I found the explanation: The general.config.obscure_value preference specifies
how the configuration file is obscured. Firefox expects that each byte in the file will be rotated by the specified value. The default value is 13. If this value is left unchanged, then the configuration file must be encoded as ROT13. Autoconfig will fail if the cfg file is not encoded as specified by this preference. A value of 0 indicates that the file is unencoded-- i.e. it is unobscured plain text. It is recommended that you set this value to 0. (This will allow you to skip the encoding step in part 3.) |
Yep, that should be a function that varies on time of year, speed of solar winds, the alignment of the planet, and the number of people are walking east versus the number of people walking west. [:)] |
|
Constants aren't, variables don't.
|
|
|
|
One funny thing I just noticed is that Josh Buhler's coworker only seems to master "not" and "larger than" operators: if(!(val.indexOf(" ")>0) || !(val.length>TWO)) { And second half of above if-statement in reprise: And he probably would have used constants if there where any(It looks very much like Flash ActionScript 2.0). /Mirandir |
I suppose calling it something like "duration of earth's rotation" would be too sensible...? |
er..um... It seems you haven't even gotten that far.....
Make that.... (val.indexOf(" ") == -1 || val.length <= TWO) (I should have fixed the first half of that as well, but we know what JB's Coworker really meant...) |
|
And this isn't even counting a submission a made a while back that has these defines in a C header file.
#define FIELD_WITH_LENGTH_FIFTY 50
#define FIELD_WITH_LENGTH_FORTY_SEVE 47 #define FIELD_WITH_LENGTH_FORTY 40 #define FIELD_WITH_LENGTH_THIRTY 30 #define FIELD_WITH_LENGTH_THIRTY_ONE 31 #define FIELD_WITH_LENGTH_TWENTY_FIVE 25 #define FIELD_WITH_LENGTH_TWENTY 20 #define FIELD_WITH_LENGTH_THIRTEEN 13 #define FIELD_WITH_LENGTH_TWELVE 12 #define FIELD_WITH_LENGTH_TEN 10 #define FIELD_WITH_LENGTH_NINE 9 #define FIELD_WITH_LENGTH_EIGHT 8 #define FIELD_WITH_LENGTH_SEVEN 7 #define FIELD_WITH_LENGTH_SIX 6 #define FIELD_WITH_LENGTH_FIVE 5 #define FIELD_WITH_LENGTH_FOUR 4 #define FIELD_WITH_LENGTH_THREE 3 #define FIELD_WITH_LENGTH_TWO 2 #define SINGLETON_FIELD_LENGTH 1 |
Am I missing something here? I can see how it's a dumb thing to do, but I don't see the connection between that and the failure of long-running daemons. |
|
If that code isn't executed every day at midnight, the values will only
be right for a certain amount of time, no? But then again, 24 hours or possibly 12 hours is not what I would call long-running for a daemon.... And WTF if this code is executed at 23:59:59'99? TODAY, YESTERDAY, LASTWEEK and LASTMONTH (stupid capslockitis) might all be wrong then. |
I can only imagine that since TODAY is a constant, TODAY says the same thing as it did when the app was started as it does two weeks later. So maybe they are comparing TODAY with TOMMORROW and determining whether to exit. |
|
It might also to unwanted effects when the year changes, but I don't
know in what format today() returns its information, i.e. if the year is included. |
LOL that made my day, I have nothing to say but WTF! |
Rate makes much more sense. Duration implies that it starts and ends.... Would be awfully strange if the earth just upped and stopped rotating after 24 hours. [:D] |
Time would stop! [:D] Haven't you ever seen Superman? |
Unfortuetly his code never references an IGyroscope so he cannot detect if the earth's rotation rate was changing. Also, anybody who previously said the Earth's retation is static was incorrect ( http://www.iers.org/iers/earth/rotation/ ), it does change slightly according to the distance of planets & moons in our immediate area. Of course going with an average rotation is pretty reliable, I mean, it's not like his code is going to automate landing a probe from earth and it MUST land within a 6 inch square on Mars and he has no visual cues to go by. Wait I take that back, he might have been a coder on previous Mars lander projects.
|
|
I am reminded of an early FORTRAN system I worked on that would allow
you change the values of constants by passing a constant to a function which changed to value of the parameter. So you give the constant value 3 a value of 5 so that wherever else 3 was used it use 5 so the expression 3 + 2 would calculate to 7. Then that fancy virtual memory came around and people started putting the values of number in protected pages and it took all the fun out of it. |
On the ZX81 home computer, using the built-in BASIC, it was a common coding practice to do something similar; e.g.
Hard to say if this is a WTF without knowing the background; sometimes similar code is the right way to avoid a date switch-over during processing which would cause bad effects. Of course, your program should run into these lines at least once per day ;-) |
So true, thanks for the laugh |
|
I ended up doing this recently. I think I was feeling allergic to new that day.
private static final Integer INT_1 = new Integer(1); private static final Integer INT_2 = new Integer(2); public static final Integer MAGIC_COLUMN_A = INT_1; public static final Integer MAGIC_COLUMN_B = INT_2; public static final Integer MAGIC_THINGY_X = INT_2; public static final Integer MAGIC_THINGY_Y = INT_1; public static final Integer MAGIC_THIUGY_Z = INT_1; etc. |
|
Thank god for design patterns, though. public class MyAwesomeProgram |
|
ROFLMAO @ rog. If this place allowed karma awards, that'd get one.
|
|
Wa?? @ Rog
Anyways, I've been wondering why people make getIntance() methods. In what situations is this a good idea? |
|
Looking at:
// Name Wonder if '...' is more usefull as a FULL NAME or FULL ADDRESS than '.' or 'abc' or any other random 3 character cr*p. |
|
BTW, on that last one: "Obscure" is to be thought of as a verb, not an adjective.
Basicaly, this value is subtracted from the ascii value in config files, so that the files are "obscure" |
Haha What the hell was I thinking... ?? [:$] Can I join the "Have-made-a-big-wtf-club" now? [:P]
/Mirandir |
The other common trick was to use 10 LET I=PI / PI instead of 10 LET I=1 This was because the ZX81 used a tokenised BASIC, with PI only taking one byte. Therefore, PI / PI actually took 3 bytes to declare the numerical value '1' as opposed to 5. Ahhh, those were the days! |
|
>Anyways, I've been wondering why people make
>getIntance() methods. In what situations is this a >good idea? getInstance (or similar) is generally a symptom of the http://c2.com/cgi/wiki?SingletonPattern The link provided explains in excruciating detail what the pattern is about, advantages, pitfalls, how it is commonly abused and why, etc etc. If you've not come across the concepts of singletons before, I would strongly suggest buying the 'gang of four' book and spending some considerable time browsing the c2 wiki. This is liable to reduce the WTF:LOC ratio of your work considerably[1]. Simon [1] Unless it doesn't, of course |
That's awesome. |
|
This forum software, however, is not. :/
|
|
Hey Tufty, thanks for that website. They have a number of interesting things there. [:)]
|
|
Somehow this reminds me of $TEXMF/tex/latex/base/latex.ltx[/code:
\def\@vpt{5} \def\@vipt{6} \def\@viipt{7} \def\@viiipt{8} \def\@ixpt{9} \def\@xpt{10} \def\@xipt{10.95} \def\@xiipt{12} \def\@xivpt{14.4} \def\@xviipt{17.28} \def\@xxpt{20.74} \def\@xxvpt{24.88} Seems like Roman eleven and twenty-four were half a percent smaller than ours, but to make up for this, seventeen was 1.6% larger, fourteen almost three percent and twenty as much as three point seven percent larger. |
The only way this makes any sense whatsoever is if it was mixing postscript and classical print point sizes. Although that still doesn't explain the roman numerals. I've been guilty of making one-time-use constants and placing then right before the function definition. >.> |
|
On the Power PC (and maybe on x86 too) constants may have bad data
locality and take two instructions to load. Using gConsts.zero rather than 0.0 may end up taking half as many instructions if a bunch of constants are used in a function. This is because it only has to load the address of gConsts once then it can just use offsets to get the other values. |
Might I suggest that if you don't know what a singleton is that you get a book that you can actually read and follow through like "Refactoring to Patterns". The GoF book is really good, but it's a reference book, not a book for learning. |
I believe the original was "Constants aren't. Variables won't." |
|
Look like artifacts from an original source written in COBOL some decades ago. Often to be found in prgs for accounting and financial calcs. Found some which made their way from COBOL through dBase to Access aso. I have an idea of beeing a very old sick man in a hospital and there is a holographic avatar serving me ... and it looks like pacman. [*-)] |
Don't laugh... one day it will happen to you! I have seen this in lots of code before. What happens is some idiot writes the initial system, then all of a sudden it stops working because totalGlue is allowed to be 9, and not 8. So what's the easiest change to make? Just bump it up to 16. Of course the dickhead who did this without renaming the constant should be shot. And they should have renamed it to "MAX_GLUE_AMOUNT" or something.
|
|
This goes back a looong way. I beleive the original K&R suggested using the line
#define PI 3.14159 should "the value of PI change in future". |
|
private const int INT_ZERO = 0; At least he's prepared if 0 would change to 100,01 in the very near feature. Same with the fact that soon today will be known as 'the day after tomorrow'. Surely you've thought of that designing your apps ? [^o)] |
Well, the Roman numerals are there because TeX does not allow digits in identifiers, so they're justified. And yes, it is a point size conversion - although it's still strange to define "20 pt" as "20.74" using a macro. |
I'm pretty sure it wasn't K&R but some Xerox FORTRAN manual. It was used it many fortune files with this annotation. |
er..um... It seems you haven't even gotten that far... !(val.indexOf(" ")>0) allows spaces in the first position (position 0) while val.indexOf(" ") == -1 don't! And it is obvious that we should allow spaces in pos 0 ;-) /Olle |
|
Is it just me, or did I find PAUSE_BY_6_SECONDS to be completely
reasonable? I.e. if I use the literal "6000", is it obvious that is six seconds? Far too easy to accidentally type "600" or "60000" ... tekra |
|
It should use a better name that doesn't include what the current
literal amount is. Like: PAUSE_DURATION. If there are multiple pause durations(6 seconds, 12 seconds, 18 seconds for example), then you should append meaningful names like SHORT, MEDIUM, LONG. All IMO. |
It is just you. It should be PAUSE_FOR_LEGAL_MINIMUM_TIME That way when congress changes the legal minimun to be 9 you don't have to change the name of the constant. 6 seconds is the value today, but it might not work out for a faster machine in the future. |
He just wanted to check F and 11 on the hacker purity test. Not to mention 8C http://www.armory.com/tests/hacker.html That might be enoguh to get his score out of the single digets. |
"Refactoring to Patterns" is indeed a great book! But I can also stronly suggest "Head First: Design Patterns" An amazing book! regards, Jeroen Vandezande |
| « Prev | Page 1 | Page 2 | Next » |