Magazines, Books and Articles

Sunday, January 25, 2009

A for Ajax, Part 5: Object Oriented JavaScript, JavaScript libraries

JavaScript is the glue that makes Ajax work. It is the only language through which we can create Ajax enabled front-ends.

As ASP.NET developers, our approach when we need to use JavaScript in our applications is to ‘Google, copy and paste’, with some modifications, if required. But Ajax enabled web applications are serious applications and require a much better understanding of the language.

Ray Djajadinata in Create Advanced Web Applications With Object-Oriented Techniques writes: “Indeed, until recently, I’d always been able to get by with whatever little JavaScript I knew, armed only with the MSDN DHTML reference and my C++/C# experience. It was only when I started working on real-world AJAX applications that I realized how inadequate my JavaScript actually was. The complexity and interactivity of this new generation of Web applications requires a totally different approach to writing JavaScript code. These are serious JavaScript applications! The way we’ve been writing our throwaway scripts simply doesn’t cut it anymore.”

And continues: “I didn’t learn JavaScript of my own volition. I had to pick it up quickly because I realized that I was ill-prepared to work on a real-world AJAX application without it. At first, I felt like I had gone down a few levels in the programmer hierarchy. (JavaScript! What would my C++ friends say?) But once I got over my initial resistance, I realized that JavaScript was actually a powerful, expressive, and compact language. It even boasts features that other, more popular languages are only beginning to support.”

JavaScript’s object-oriented approach is different then a conventional object-oriented language such as C#. However it brings to your applications the same advantages you derive from a conventional OO language. OO Javascript may seem quirky at first, but as you get up to speed, you begin to appreciate its awesome power. You also realise the discipline required so you don’t abuse its power.

For complex projects, it is best to use a JavaScript library. JavaScript libraries extend Javascript to make it even more powerful. A few examples:
ExtJS provides you with an excellent collection of controls for the front end.
Microsoft’s Ajax Library extends JavaScript “objects to give them the richness of .NET Framework classes”.
jQuery is important for ASP.NET developers if only because Mirosoft will be using it in a big way in ASP.NET 4.0.

For those on the ASP.NET platform, knowing how to use the Microsoft’s Ajax Library and JQuery would certainly be an asset.

Further reading
A re-introduction to JavaScript
Code Conventions for the JavaScript Programming Language

Microsoft AJAX Library namespaces
jQuery and Microsoft

David Flanagan, JavaScript: The Definitive Guide, 5th Edition, Wiley Publishing, Inc., ISBN-13: 978-0596101992
Douglas Crockford, JavaScript: The Good Parts, O'Reilly Media, Inc., ISBN-13: 978-0596517748
Stoyan Stefanov, Object-Oriented JavaScript, Packt Publishing Ltd., ISBN-13: 978-1847194145
Ross Harmes and Dustin Diaz, Pro JavaScript Design Patterns, Apress, ISBN-13: 978-1590599082

Bear Bibeault and Yehuda Katz, jQuery in Action, Manning Publications, ISBN-13: 978-1933988351
Jonathan Chaffer andKarl Swedberg, Learning jQuery, Packt Publishing Ltd., ISBN-13: 978-1847192509
Jonathan Chaffer andKarl Swedberg, jQuery Reference Guide, Packt Publishing Ltd., ISBN-13: 978-1847193810

Shea Frederick, Colin Ramsay and Steve 'Cutter' Blades, Learning Ext JS, Packt Publishing Ltd., ISBN-13: 978-1847195142

Video links (from Mix 11):
Mix 11