JavaScript Tutorials
JavaScriptDebugging JavaScript Outside Alerts
Debugging an application especially with a client side programming language is an essential task for developers. The application will always look great at first glance without debugging. But with debugging, developers should be able to point out functions that may not work well when the application is placed under great stress.
An online application that didn't go through various debugging techniques will most likely fail. Functions and other variables in an Ajax or any client side programming languages will always have some problems on their first use. With debugging, developers will also be able to improve their application considerably.
Traditionally, developers would resort to alerts to actively monitor some challenging functions in an application. This technique offer developers the ease on working with other functions as the debugging tool will actively monitor the application on the background.
But alerts on debugging JavaScript and Ajax based application only solve half of the problem. JavaScript and Ajax can only use alerts as debugging tool to monitor small functions that may not be directly related to optimizing the online application. Alerts will also be relatively difficult to implement since they have to be placed in various lines just to actively monitor certain functions.
Multi-Threading as the Culprit
The main reason why developers will have a hard time maintaining the application with alerts only is multi-threading. This is the unique function of JavaScript, Ajax and other client side programming languages that can create an online application. A basic website will only have a single thread since it will merely request data from the server and load the information on the browser. Alerts can easily monitor this exchange of request and can inform the developers if there's any problem in the website.
Multi-threading on the other hand, uses more than a single line of information and function requests. This is essential since the online application has to do two or more functions at the same time to cater to user’s requests. Alerts can't monitor each requests for data and functions since most are implemented at the same time or with very little interval.
Using the Best Debugging Tool: Your Browser
Of course, developers still can manually implement alerts in specific areas in an Ajax or JavaScript based application. But this technique will take time and resources as they have to be manually implemented. Besides, there's a better debugging tool that you can use: browsers.
Browsers have a great way of monitoring what's wrong in an online application. Since browsers will ultimately become the recipient of the application, it's just proper that browsers should be able to monitor the state of the application.
But don't expect that every browser would have this function. As of this writing the best browser that could help developers in maintaining an efficient Ajax or JavaScript based application are Mozilla-based applications. The presence of Firebug has pushed the browser in becoming a powerful debugging tool.
The ability to read JavaScript functions efficiently has also made Firefox an almost authority on how to work with various client side programming languages. Use the browser so that you’ll able to debug your Ajax based application.
Comments
Juan Mendes said:
|
It is wrong to say that using ajax makes your js app multi-threaded. A js "thread" is never pre-empted by another js thread in the same window. There is only one thread for handling javascript execution. It is correct to say that it is asynchronous. However, asynchronous and multi-threaded, though related, are not the same thing. In js, you never have to worry about reading a global variable and worry about its value being changed before your method executes. Having said that, an inner method could be called asynchronously and a closure variable may have been changed. Another problem would be if you have to break your long running functions with setTimeout. When you do that, you are basically giving up your place in line, meaning you should check any global (or shared closures) once that method is called again. That is unless you've broken up your method with setTimeouts, then other js asynchronous code |
Sponsored Links
