- 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
I had something funny to say, but akismet says my comments are all spam. Forget it.
Admin
Admin
Censored TFY.
Be careful. Criticism of, or even mentioning Asshat, is known to invoke the wrath of Asshat. Allegedly.
Admin
Where is the unit test?
Admin
I'm now tempted to find out if various compiled languages optimize those ifs away.
Admin
Anyway, I did get around it. I deleted everything interesting from my comment, and Akismet let me right through. Success! (Hey, I still get to laugh at the joke, so it's a win as far as I'm concerned.) :>
Admin
Admin
To save the reputation of european coders:
No, "break" only breaks out of the nearest loop or case-stetement (or, if labled, the labled loop) - No way break can ever break out of any compund-statement (block)
No, the readyState can't change while the code is executed. JavaScript is single-threaded, all events and their callbacks are atomic. (Therefor the inner "if" is just scattering while speaking JS.)
Yes, it's quite reasonable to check the status and readState==4 is the right place to do it.
It's totally ok to use hardcoded numeric values in JS, since a) JS allows only for hard-coded case-labels (and the value checked is numeric). b) The values are part of the underlying protocol. They are not expected to change. (This would not be true while dealing with protocols not frozen yet like web-sockets. But XMLHttpRequest is a frozen standard.)
OMG!
Admin
Agreed. I was about to post nearly the same thing. There is nothing wrong with this code other than slightly inefficient and it is likely that the coder intends (or intended) to do more with it down the road.
Admin
unless of course he just threw in the breaks as a place holder until we could write in some code to handle the other states.
Admin
First i was like "O so he checked for statuses he didnt care about.. ok whatever" .. but than i saw it and i shited bricks!
Admin
This code is reminiscent of a lot of awful VBA code I have witnessed over the years. Lack of the use of CONSTANTS and the lack of the application of ENUMERATIONS just smacks of a lazy or incompetent programmer. I guess both is also possible.
4 is just a number. In the context of this code, what does it mean ? That's the question.
Admin
It's computing using quantum physics. The state of something might change just by being observed
Admin
If at some point you need to do some conditional processing inside one of the case statements, then add an if at that point. The ease of updating code is kind of the entire point of having high-level languages which are easy for humans to write.
This seems like the opposite of "premature optimisation" - premature expansion perhaps? If there is no reason for the code to be there, then it shouldn't be there. The only way that I'd think it was a good idea would be to have the empty case statements there with a comment along the lines of /* TODO: update widget when this state occurs */ or similar.
Admin
'dats the most explicitish thing I eva hoid.
Admin
Ah, so now we have racism and ableism.
Would any more bigots like to show themselves?
TRiG.
Admin
Ah, so now we have racism and ableism.
Would any more bigots like to show themselves?
TRiG.
Admin
Admin
Achat mГ©dicament en ligne fiable https://kamagraenligne.com/# pharmacie en ligne france fiable