You mean this bug?
I can't even tell if it's already fixed, will be fixed in FF30 or whatever...
You mean this bug?
I can't even tell if it's already fixed, will be fixed in FF30 or whatever...
@dkf said:
@Strolskon said:So “int my_isdigit(char c) {
return ((c - '0') < 10);
}!
” is a digit?
That one's fun because whether or not it works depends on the compiler. ('char' may be signed or unsigned.)
And we've switched compilers over the years on this project. Guess what one of the differences between them is...
Although converting strings to numbers is a common WTF, this one -- which I found when debugging some code that was giving bizarre unexpected results, and presented exactly as it is in our code -- has some real gems.
Possibly my favorite part is that based on the function names, whoever wrote this code knew that standard library functions existed to do this job, but they decided that they could do a better job of it themselves. Bonus points for defining my_atoi which one would expect to be a reimplementation of atoi(), but in fact does something completely different.
unsigned long my_strtoul(char* str, int base) { int str_size = strlen(str); #define MAX_STR_LEN 8 int ival[MAX_STR_LEN] = {0}; unsigned long ret_long = 0; int i,j; unsigned long tmp_val; if (str_size > 8) { str_size = MAX_STR_LEN; } for (i=0; i<str_size; i++) { if (base == 10) { if (!my_isdigit(str[i])) { str_size = i; break; } } else { if (!my_isxdigit(str[i])) { str_size = i; break; } } } /* end for */ for (i=0; i<str_size; i++) { ival[i] = my_atoi(str[i], base); } if (base == 10) { for (i=0; i<str_size; i++) { tmp_val = ival[i]; for (j = (str_size-1); j>i; j--) { tmp_val *= base; } ret_long += tmp_val; } } /* base 10 */ else if (base == 16) { ret_long = 0; for (i=0; i<str_size; i++) { ret_long |= (unsigned long) ival[i]; if (i != (str_size -1)) ret_long <<= 4; /* shift by 4 bit */ } } /* base 16 */ return ret_long; } int my_isdigit(char c) { return ((c - '0') < 10); } int my_isxdigit(char c) { return ( ((c - '0') < 10) || ((c - 'a') < 6) || ((c - 'A') < 6) ); } int my_atoi(char a, int base) { int i = 0; if (base == 10) { if (!my_isdigit(a)) return -1; } else if (base == 16) { if ( !my_isxdigit(a) ) return -1; } i = a - '0'; if (base == 16) { if ( (a == 'a') || (a == 'A')) i = 10; else if ( (a == 'b') || (a == 'B')) i = 11; else if ( (a == 'c') || (a == 'C')) i = 12; else if ( (a == 'd') || (a == 'D')) i = 13; else if ( (a == 'e') || (a == 'E')) i = 14; else if ( (a == 'f') || (a == 'F')) i = 15; } /* end if (base == 16) */ return i; }
@joe.edwards said:
Hint: 80s movie with a catchy theme song that translates well to midi
Harold Faltermeyer - Axel F.
Do you want see the extreme end result of such taxes / national insurance?
Then come to Germany:
edit: why is this forum appending my greasemonkey script? once for every edit
@BC_Programmer said:
I can think of: either the language itself sucks, or the toolset sucks. I'm simply more inclined to believe the latter.
BorlandEmbercado made some big mistakes:
* No free for open-source edition of every version. A language cannot get popular, if there is no free compiler
* Screwed up Kylix. VCL is an amazing wrapper over the Win32-API, but many people need a Linux version
* Rewriting everything in .NET
* Adding generics too late<script>window.alert = function(m) { if (!confirm(m)) var kill=asdsadapfksaoOPSFKPASKOPFS; }</script>
@blakeyrat said:
harms you either physically or financially
But, guess what, I don't like it. I don't like clicking somewhere once and having that haunt me for a week. Just as I don't like building an identity in forums or posting everything I do on twitter. You probably won't understand "why" but I just don't. I can't explain why I don't like the smell of rotten fish either (not talking about evolutionary explanations).
But every time you see someone here who does anything you don't do you throw a tantrum. You probably are the kind of person who wonders how the hell can gay men be attracted to other men if other men don't have boobs.
I remember I browsed some time with a google account and no third-party content blocker. I clicked an ad once and for several weeks ALL ADS on every page became that ad. Even worse, Youtube kept asking me to watch the same MLP:FiM episode for over a month. No thank you, I'll watch what I want.
I don't consider this so much "WTFy".
When deciding whether a design a good or bad I'd say use these criteria:
1. Does it require lots of redundant code/boilerplate? (This is a problem because it slows down development)
2. Would a single change in the requirements require lots of changes in many different places? (This is a problem because one may forget to change one of these places when implementing such a change)
3. Is there a risk a future developer misuses the design and thereby creates bugs?
4. Is it a well-known pattern? (If not, it is a problem because new developers have to learn the pattern first)
Now let's analyse this design.
1. The redundant code is the app passed to every single application element constructor, and the fact that all dao accesses need to be written app.dao instead of just dao. I'd say this is pretty minor. Note that using a singleton pattern "Application.getInstance().getDao()"is not that much shorter especially as you now need to write the implementation of getDao().
2. Not really. You want to change the dao implementation by another one? Only modify Application. You find out MyFrame has another dependency (in addition to dao)? Just access it through application - no need to modify Application or whatever code instanciates MyFrame.
3. There are two risks here: first Application.dao is writable, so a developer might be tempted to *modify* Application.dao from another place (which is the reason people say globals are "bad" - because they can be modified from a method without the method signature making this evident). This could be avoided by marking dao as final in application, and adding an Application constructor to pass custom dao implementations (for use from e.g. unit tests). Second risk: there's a Singleton pattern at use here (people assume there's only one application instance so that everytime someone writes app.dao they access the dao of the same app, and therefore the same dao as well), BUT people might be tempted to pass a new Application instance. Solution: mark Application's constructors as private (or maybe package private), [OR mark dependencies (dao and others) as static - in that case you no longer need to pass the application instance. This second solution is less good because it prevents you from making unit tests with different dao implementations AND still having dao marked final.]
4. This is not the most usual way of doing dependency injection, which is probably why the first reaction is WTF. But it doesn't IMO have issues itself.
(Using a dao directly instead of having a service layer is another issue that I did not cover above. That MAY be a problem if data has/may have in future integrity/consistency requirements that would need to be implemented in a service, but it is orthogonal to my analysis above - nothing would prevent Application having a public Service attribute, and have the Service itself use a Dao).
(PS I accessed this account through bugmenot - treat this as slashdot's anonymous coward ; I did not write or even read any of Strolskon's other posts)
@pauly said:
I know that FOSStards like to turn on the stupid-act when they sit in front of a Windows machine, but this hosts file thing is too much. Stop acting like you don't know how to change the NTFS permissions on that file.
You want a thread about dicks? Alright then. I'll just drop this here:
It is relatively common for straight men to be attracted to penises.
Hopefully you'll get a nice long thread now.
Bonus: a TED talk about penises.