Κάνοντας blogging, έπεσα πάνω στο παρακάτω post, που προσωπικά το βρήσκω απόλυτα σωστό, και παρουσιάζει το πρόβλημα του remote scripting:
1 | Why AJAX is dangerous... My Daily WTH (What the heck?!!?) | r | I made an interesting discovery at work today. I finally had to work on a piece of code that I have always found ways to hand off to someone else. It was written by a former colleague who absolutely loved JavaScript and Remote Scripting (aka AJAX... don't argue with me they are the same thing more or less). Every programmer who has ever had to do something with this code has hated it (except the originator). BTW, this is ASP code. So before I continue on, I would like to ask everyone a question. How many lines of Javascript is too many in a page? When do you start thinking about moving that functionality out of the page and back on the server? In other words, when is it OK, to go ahead and post back to the server. How many lines? Ok, pencils down... what do you have? A couple hundred? One thousand? Fifteen hundred? So you would say that 5000+ lines of JavaScript is too many (I hope so).... the entire application is written in JavaScript with remote calls to retieve data. BTW, data is returned from these routines as delimitted strings (with one delimitter for a record and a different delimitter for each field in the record). This data is then pulled apart using that high-tech JavaScript method split... Can you say sssssslllllooooooowwwwwwww? It also creates new HTMLelements on the fly which is also not the fastest method of doing things. Oh yeah, and where was this code? Not in a separate file incuded via a script tags src attribute... No... this code is dropped into the top of the ASP page, so that the ASP <%=%> could customize the page and keep the page from being cached by the browser... BTW, when I removed the non-customized JavaScript and put the 5000+ lines into a separate file the resulting .JS file was 266kb! Am I allowed to rewrite? Of course not! <sigh /> Those of you who love AJAX, please be responsible when you are evangelizing the technology and remind people that doing everything with JavaScript/AJAX may not result in a speedier solution. It may result in something less maintainable and/or less speedy... Original Link | |
George J.