| « Prev | Page 1 | Page 2 | Next » |
|
What kind of idiot knows Javascript, but doesn't know that you can (and should) put client-side event handlers into methods? Especially since he already is calling methods in the onclick code. Javascript ain't ASP.NET, buddy. There's no separation of code/presentation unless YOU make it happen.
I'm guessing this is the result of a lazy programmer. "Eh, I wrote it and it works, so I never need to touch it again unless something is wrong." |
Re: OnClick Does What?!
2008-01-21 08:17
•
by
Not Dorothy
(unregistered)
|
The situation is thus. You are a code monkey (JavaScript in this case), you are given a task - validate the input on this form. You sit in the dark being fed your tasks by you wise, all seeing project manager. The JavaScript monkey has not screwed up, his project manager has. Since when did the code monkeys have any input into a project? |
|
Omg i didn't even know that you could have multiline code inside an event handler? Thank god for tagsoup parsers :D
|
How true that is :( Because, we all know the project manager, despite having never really written software, knows all about how it's written and how to manage those silly programmers who always talk about "refactoring" and "testing" instead of producing code that Sales can sell to clients so the CEO can earn his millions. |
|
how did the quotation mark(s) inside an attribute value ever work?
|
flag = validateRecord(form.res_Addr_1,form.res_City_1,form.res_County_1, form.res_State, form.res_Zip);All this silly indentation... if (validateRecord(form.res_Addr_1,form.res_City_1,form.res_County_1, form.res_State, form.res_Zip) && Why do so many programmers don't know bit operators? |
|
Can someone explain why this is a WTF for people who don't have a clue about web development?
|
Re: OnClick Does What?!
2008-01-21 08:37
•
by
Vollhorst
(unregistered)
|
... like myself. Damn... remove the bit bit. ;) |
Re: OnClick Does What?!
2008-01-21 08:37
•
by
Phleabo
(unregistered)
|
I have no idea what point you're trying to make. Are you trying to say that the project manager mandated that the coder not use functions or other basic hallmarks of good style? |
|
I wonder if they check password with JavaScript on client side as well
|
|
I can't agree with the fact that the PM screwed up. I would rather say that the recruiting/HR department did. This is stuff you just have to question and not take for granted even if you are just a coder. And if you really are a monkey, at least you could do is ask yourself "is it really normal to have such a long string as an attribute value? All other attribues seem to be a lot shorter. Hmmmmmmm".
|
Re: OnClick Does What?!
2008-01-21 08:58
•
by
Nulla
(unregistered)
|
|
Perhaps it's the same reason that some don't know the difference between a bit operator and a logical operator.
|
There's a 66 line javascript function inside an HTML attribute. Attributes are never supposed to be more than a few words. The correct way to handle this would be to put the javascript somewhere else (like, in an actual function declaration) and call it from the handler, or even better, put an onload function somewhere that attaches the onclick handler at start so there isn't any javascript in the HTML at all. |
Re: OnClick Does What?!
2008-01-21 09:24
•
by
Vempele
(unregistered)
|
if (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))) { will work just fine assuming those functions don't have side effects. :p |
Re: OnClick Does What?!
2008-01-21 09:32
•
by
me
(unregistered)
|
Aha! So that's what he was talking about. I read that post like three times trying to figure out where bit operators had anything to do with it... |
Re: OnClick Does What?!
2008-01-21 09:33
•
by
Stupidumb
(unregistered)
|
Those aren't bit operators. |
Because they're two-bit operators? |
Re: OnClick Does What?!
2008-01-21 09:36
•
by
Pez
(unregistered)
|
There should also be a server side failback so users who have Javascript turned off still get the same functionality. Helps usability and security no end. Personally, I wouldn't bother with Javascript validation and just do it on the server |
|
Unless you are coding in LISP, where you may end up with 7,8,9 levels of nested brackets to close, adding this kind of crap to code is just annoying.
} // end if especially when the opening if statement is THREE lines above! |
|
I dont know to me it looks like this is Five-fingered code that someone who didnt know better, like a marketer or graphic designer slapped into the page. The annoying comments are somethings that you keep your place as a new programmer, 2-3 weeks maybe, or when you get paid by the line.
|
|
Hmmm, why does the post have a vertical scrollbar (especially since only one line is hidden)? And, more importantly, why does it have a horizontal one? (1024x768)
|
I bet his name is Habib Abdul Habaldoasdkdsdkfdsusmuck. |
|
It's a little known fact that Dante's Inferno is actually a metaphorical description of JavaScript:
"Dark, profound it was, and cloudy, so that though I fixed my sight on the bottom I did not discern anything there." |
I believe you mean "functions", not "methods". |
It's a two parter. First, the coder is doing all of the validation on the client side (web browser). Which violates one of the first rules of web programming: Don't Trust What the Client Sends. It is trivial to turn off javascript thereby skipping all of the client side validation. All of this code should have been processed on the server as well. Second, readability is a nightmare. So, instead of putting all of the javascript code inside of an HTML attribute, it should have been stored in either its own javascript file or in the page header. This would leave a simple, very readable, function call as the button's onclick handler. |
Re: OnClick Does What?!
2008-01-21 10:51
•
by
JK
(unregistered)
|
|
=================
if (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)){ Why do so many programmers don't know bit operators? ================= Ummm... those are LOGICAL operators, buddy, not bitwise operators. Quite a difference. |
I'm not wholly convinced. Sure, the lack of server-side validation is dumb, but that happens too often to merit a WTF. I don't really see how "readability" is a nightmare, either. Firstly, it's Javascript. Javascript is not readable, IMO. Secondly, it would be equally unreadable if wrapped in a function call. What I think we have here is a Perl programmer trying to carry the concept of anonymous subroutines across to Javascript. Not the world's brightest idea, granted, but more of a giggle than a WTF. |
Re: OnClick Does What?!
2008-01-21 11:01
•
by
vigge
(unregistered)
|
Although those aren't bit operators in your example, are they (afaik they're called logical operators)? |
Re: OnClick Does What?!
2008-01-21 11:02
•
by
KM
(unregistered)
|
|
There _are_ anonymous functions in Javascript.
|
Re: OnClick Does What?!
2008-01-21 11:06
•
by
Anita Job
(unregistered)
|
Validating user input on the client side _in addition to the server_ can improve server performance by reducing the number of calls to the server that contain invalid data, and the subsequent calls needed to resubmit the corrected data. CAPTCHA: 'duis' - Don't drink and drive and you won't get any! [~]) |
|
At least its commented!
// end comment |
I think he's saying that the coder just wrote the code, and then the manager told the HTML guy to put that code into the onClick; the JS coder didn't know that the code he wrote would be shoved into an HTML attribute |
Re: OnClick Does What?!
2008-01-21 13:18
•
by
John Doe
(unregistered)
|
|
Ouch, did we hit a new low when merely the use of functions is considered a "basic hallmark of good style"?
At least the guy was using functions for the validations... |
Re: OnClick Does What?!
2008-01-21 13:47
•
by
rbonvall
(unregistered)
|
There is no wooden table. |
I bet you're a retarded redneck racist moron, but unlike you, I have at least *some* evidence for my theory: your own words. |
|
My theory was that some sort of GUI generator tool did that, I've never, never seen anything vaguely resembling that before and it looks like someone just typed a whole script into an OnClick() prompt in a prompt somewhere
|
We hit that low a long time ago, Winston. |
|
Wouldn't that have broken by the first " character?
|
|
I guess he used something like
<input onclick="<?php include 'script.js' ?>" ...> |
Re: OnClick Does What?!
2008-01-21 16:03
•
by
Barf 4 eva
(unregistered)
|
heh, methods or functions? :P Sounds like a meaningless and improper OR statement to me, but then again... Perhaps this is a point clarified specifically within javascript? I don't do JavaScript... buuuuut.. I always believed a method to be a generalization of EITHER a procedure OR a function, where method is more inclusive, in which case, a function is a method. |
Re: OnClick Does What?!
2008-01-21 16:23
•
by
Ahnfelt
(unregistered)
|
A truly lazy programmer knows that this will cause trouble later on, and tries to get it first the right time so he doesn't have to touch it again. Don't mistake incompetence as laziness. Laziness is a virtue in programming and any other field where you have to maintain what you've built. |
Function verb(object); Method object.verb(); An oversimplification to be sure, but it gets to the heart of the distinction. And Javascript does support both approaches. |
Re: OnClick Does What?!
2008-01-21 17:01
•
by
Habib Abdul Habaldoasdkdsdkfdsusmuck
(unregistered)
|
Casual racism never goes out of style, does it? |
Re: OnClick Does What?!
2008-01-21 17:35
•
by
Barf 4 eva
(unregistered)
|
heh, thanks for the explanation, do appreciate it! I THINK what is meant, and I'm probably off (have a tendency to be..) is that a method exists via instantiation of an object whereas the function is a static implementation? (IE: I use a static class such as the Math lib to use the static math FUNCTIONS) I never hear much about the difference between methods and functions in C#, but I figured this is what you were getting at maybe? :P Sorry, from a Delphi perspective (don't ask!) you have procedures which don't return anything vs functions, which have a return type -- I used this as the basis of all existing as methods. Again, thanks for clarifying! |
|
oh man, that's awesome that scrolling wrapper around the article that means the stupid thing is unreadable because every line extends off to the right of the div... *clap*
|
Re: OnClick Does What?!
2008-01-21 18:03
•
by
Code Monkey Like Fritos
(unregistered)
|
Code monkey very diligent, but his output stink. His code not functional or elegant, what do code monkey think? Code monkey think maybe manager wanna write god damn login page himself! Code monkey not say it, out loud code monkey not crazy, just proud. |
Re: OnClick Does What?!
2008-01-21 18:42
•
by
mabinogi
(unregistered)
|
That's a pretty meaningless distinction. In that example, method is the name people give to member functions of a class when they want to sound like they know Object Oriented programing, but don't know it well enough to call them messages. A method or message is a function that is designed to operate on or expose the internal state of an object. It's entirely possible to have verb(object) functions that are actually methods - particularly in non natively object oriented languages, and it's also equally possible (but not necessarily good design) to have object.verb() functions that are just functions, and do nothing with the state of the object they're bound to. |
|
Oooh.. this looks like something Brice Richard would do if he knew javascript!
And speaking of truncation, anyone else notice that the wtf text has a scrollbar? But it's long enough so that you can't see the bottom scrollbar. It's effectively truncated unless you're running a full screen browser at ~1600x1200 or better (at least in IE7)! |
That's another good theory. I still like my Perl theory, though (if only because CGI makes it reasonably plausible):
And presumably committed Javascript programmers are unable to discriminate between the "Reply" button and the "Quote" button. Never mind, at least I know what you mean. Yes, thank you, I know there are anonymous functions in Javascript. But why bother with all that "function(blah) { // Further blah, possibly involving the DOM } when you can just encase the whole lot in double quotes? Genius, I tell you, genius. And admittedly the OP doesn't look like Perl's anonymous subroutines (leaving aside the stuff to do with closures). Yup, Perl is almost equally verbose: sub # No blah here!\n { # blah\n }. However, the great thing about this particular idiom is that it effectively combines Perl's anonymous subroutines with Perl's "here-doc" technique to provide what any Java programmer worth their salt would recognise as a Singleton Pattern. Brillant! Brillant!! Brillant!!! Of course, it's still bloody stupid. BTW, Is it just me, or does ECMAScript sound like a peculiarly horrible combination of tattoos and a rather unpleasant skin disease? |
| « Prev | Page 1 | Page 2 | Next » |