- 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
That has to be the longest HTML tag ever written!
Admin
Indeed, only server-side validation can be trusted. The client-side validation is there purely as a convenience to the user, and to save a client/server roundtrip for innocent mistakes.
Admin
Where, exactly, is this "separation of code/presentation" of which you speak?
Which bit is the code? Which bit is the presentation? Where is Waldo?
I'm looking forwards to being yelled at, and probably for good reason, but most of the complaints I'm reading don't seem to be about "bad code" or "bad practice;" they seem to be more on the level of religious fundamentalism. You have to do this, you have to do that, you have to wash your feet aftwerwards, and make sure you don't say "See you next Wednesday." (Oops, sorry, that last bit is movie fundamentalism.)
Seriously. Most of this stuff is irrelevant syntactic sugar. You want a proper language, go get a proper language. (Lisp, Scala, Python, Cobol, Algol68 ...) Don't try the superior Conehead on with the rest of us, who have to actually deal on a day-to-day basis with the mess that is the Web.
Damn. Missed PHP4 out in that list, there. Can't quite remember why.
Admin
Why do don't you know grammar?
Admin
This code definitely doesn't work at all. The attribute is enclosed by double quotes and it would die at
with a syntax error.
Please note as well that not all browsers will allow line breaks inside attributes.
Admin
Those aren't bit operators! Those are logical operators.
Bit operators are & and | (only one).
Admin
Because that's a f*ing pain to debug. And no known debugger allows me to step into just one of those calls.
M.
Admin
Congratulations! You are the <insert appropriate ordinal I can't be bothered determining here> person to make this observation. First place of course went to the person who originally mentioned bit operators, who used the obvious unfair advantage of getting to read it before the rest of us and made the correction in less than two minutes. Still, your contribution has been noted.
Admin
Admin
Well ... It think they know about bit-operator.
Unfortunately most of "debugging" tools are unable to show results of intermediate calculations (calls to validate in this case) In this case it means that without stepping into specific functions you don't know which returned what. So those are in fact "debug by printf leftovers", it's my bet.
I believe that in some somewhere after xxxflag = something() there is rarely blinking 'alert("dateflag = " + dateflag)' which is currently invisible but appears each time developer tries to debug this part of code.
(Not that i like it. I'm trying to understand).
Aha it's also "single point of exit" believer i think, but it's his problem.
Admin
"Why do so many programmers don't know bit operators?"
FYI:
'&&', '||', '!=' etc are -logical- operators. '&', '|', '~', '<<', '>>' etc are -bitwise- operators.
Admin
Admin
The real WTF (c'mon, let me use this phrase... it's the fi(r)st time I ever used it here!) is that you don't even need to disable javascript to bypass the validation.
Pressing the Enter key on one of the textfields in the form will also submit the form, and it won't trigger the onclick event. That's why you need validation in the onsubmit event of the form (as well as serverside ofcourse).
Admin
I actually prefer what Barf 4 eva said in 172407 in reply to 172398
At least in VB and Delphi (and more) a function returns something whereas a procedure (or method, who cares?) does not. Not more, not less. Surely, has nothing to do with internal states of objects (hey functions and procedures existed already in BASIC, so for sure that has nothing to do with objects) and all that crap. You can write a function that returns nothing and you can write procedures or methodz that return something by modifying the parameters which were used to execute the method or proc. That's all. It's just a way of saying it but fundamentally they are the same (at least in the way you use them).
Admin
And why do so many programmers dont know gramar?
Admin
those double quotes in the code will break the code any way. This piece of code should even execute.
Admin
"gramar"? I suppose it makes a change from "grammer" :)
Admin
Why do so many programmers don't know bit operators? About the same as don't know their bitwise from their Booleans
Admin
When I last checked, 'subroutine' was the generalization of 'procedure' and 'function', and 'method' was a fancy name for a member subroutine. Of course, in many languages the term 'procedure' is unused in favor of 'function' (AFAIK, this includes JavaScript), so in them the point is moot. (Oh, and in C++ a method is specifically a virtual member function, and every language is free to redefine the terms on their whim.)
Admin
LOL! I think you nailed it. :)
I was curious after reading the rest of the responses regarding the meaning of the terminology, and ended up just getting myself lost more than I was originally! I even ended up getting a load of different definitions from what I'd consider reliable sources... In the end, I decided I should get back to work!
For now, I'll stick with the definitions I've had in the past, which of course are subject to change dependent on the change in language used. :P
Admin
Maybe because it's not a bit operator, logical eh? :)
Admin
Umm... what has this got to do with bit operators? Your answer above uses logical operators. I don't know about JS but in most languages the bitwise and logical operators are different.
-Matt
Admin
Me fail English? That's unpossible!!
Admin
"shouldn't."
And why not? Adherence to W3C seems, to me, to be patchy at best. Good luck to anybody trying to formulate the next great Silver Bullet based on ECMA4.
There is also the possibility of pasting it into a Web page and checking it out. Maybe it executes; maybe not? How would you know if you haven't tried it?
We are basically living and working in a swamp of ill-defined "standards." Test it, test it, test it once more, release it, and rely on customers to complain.
Do either of you actually program in C++? If so, please stop, right now. VB.Net is the way to go.You're arguing over terminology. If you can't even get that right, then god help you when you have to deal with Liskov substitution, template template parameters, RAII ... to name but a few.
C++ gets a bad rep because 98% of "C++" programmers should be doing something else, like hairstyles for poodles. (OK, I'll admit that C++ has other issues, but this is by far the most important one.)
Exercises for the reader:
(1) How would you distinguish between a C++ procedure and a C++ function? Does it matter? Why? (Joined-up writing gets you an asterisk after the grade. It doesn't mean anything -- just like the question -- but it will make you happy. I promise.) (2) In C++, is a "method" specifically a "virtual function"?
I may have to go outside for a while. I believe my brain has just imploded.
Where do you idiots get this stuff from?
Admin
It's a habit of older programmers most likely, because if you use logical &&'s, the compilers/interpreters/parsers of olden times would evaluate all checks, whereas if you used "silly indentation" they knew to break out after the first one returns false.
I still do that sometimes, just because of a habit. I think most modern compilers know how to handle the single-line version well enough that it shouldn't make a difference.
Admin
Admin
So what? So you are executing broken code. Yuo will be my guru
Admin
Maybe it's best to call them Huey, Dewey and Louie. This way there won't be confusion between subs, subprocedure, method, function, virtual member and wht-do-I-know.
Admin
My own personal pet hate was this bit
stYear.push(parseInt(form.res_YYYY.value)); // start year
Why not just name the array startYear in the first place?????? Grrrrr.
Admin
"f (validateRecord(form.res_Addr_1,form.res_City_1,form.res_County_1, form.res_State, form.res_Zip) &&
validate(form.res_MM, "",form.res_YYYY) &&
validate(form.res_MM_end, "", form.res_YYYY_end))"
huh ? Hehe didnt know that '&&' was a BIT operator ;). What is a logical then ?
Admin
Just calm down. Duh.
Admin
cough like you?
I think you are getting your logical and bit operators confused!
Admin
OK, I've only poked around at Javascript (anyone know of a good book on it? I know 16+ languages already; I don't need something that's still explaining for-loops 1/3 of the way in) but even I can see what's wrong with that.
Admin
On the other hand, VisualBasic dialects (I have not confirmed this with VB.NET) tend to evaluate ALL of the operands without short circuiting. Hence, you must nest or sequence your IF statements if you do not want to run into problems.
The following pseudo code will work fine in a C based dialect, but could barf in a VB dialect with DivisionByZero.
example 1
MUST be written in VB dialects like
example 2
could NOT be written in VB dialects like
it could be written like
My guess is that the programmer that originated the code has some VB background.
I still think the real WTF is that no one ever explained the truncation issue! Was the JavaScript being ignored due to the quoting issue? The story's solution would lead me to this conclusion.
Admin
In post-.NET VB, AndAlso and OrElse are short-circuiting versions of And and Or, respectively.
Admin
In VB (at least versions 5 and 6) you have by default the lazy evaluation but can configure for exact evaluation of booleans
Admin
I have never gotten any impression that && || ! were bit operators. Seems to me they're logical operators.
Admin
What 'bit' operators??
Admin
Since when is && a bit operation? :)
Admin
I don't know. Why do so many programmers not know the difference between logical operators and bit operators?
Admin
WTF?<b>
Why, oh why, do people comment their closing brackets?