Coding, is? Fun!

Thursday, January 01, 2009

Add-In for Javascript Development using Visual Studio

I have created a Add-In for Visual Studio (2005 and 2008) that helps Javascript development. I developed it for my own use since I code now in Javascript extensively. But it is extensible enough that I have created a project in CodePlex.com for it - here: http://www.codeplex.com/CodeOrganizer.
It helps navigate Javascript; creates a very cludgy "intellisense" window; and also transfers code fragments to different regions. My purpose in creating it was to avoid scrolling back and forth in big Javascript files. When you edit CSharp and VB, you can easily navigate straight to functions and have intellisense do half the work - but Javascript editing is more difficult.
VS 2008 has very good Javascript intellisense , but it has its limitations. In our projects it does not work at all. I wrote to Microsoft about it; they are working on an improved engine apparently. Meanwhile, the add-in assists me. It is also invaluable in navigation.

If you try it out, I welcome feedback. You are also welcome to use the template to develop your own add-ins for any productivity improvement. The code is free for distribution under the MIT license.
You can view a demo (not very good quality in video) here:

Labels: , ,

Thursday, November 06, 2008

Javascript Libraries

When you are designing an application there are several paths regarding the choice of UI:
1. If the application is internal to an enterprise, you can choose a desktop application. Mostly instead you choose an application delivered through the browser to avoid installations. Even through the browser, you have options like .NET Smart Clients that are opened in the browser. You have the option of Flash/Flex or Silverlight - a consistent, rich UI experience with Drag/Drop is possible in this environment. You can also choose traditional JSP or ASP.NET applications with postbacks.
2. If the application is facing public users, then most of the above options are eliminated - you have to go with Javascript/HTML/CSS - because it is the paradigm of the web.

In both the above cases, there is a reluctance to choose Javascript to build strong UI - the reason is that Javascript programming is not very type-safe. Editors are hard to come by. There is little use of intellisense. It is still seen as just a "scripting" language. In the browser, there are still cross-browser issues in DHTML, Ajax and so on.
I wrote a post sometimes back about Object Oriented Javascript - mainly talking about simple OOJ concepts. But in the past few years, almost every month someone releases a Javascript library. Javascript libraries such as prototype are immensely popular for a few good reasons:
1. Cross-browser issues are transparently handled by these libraries
2. They provide standard controls, layout managers and a great programming model.
3. They also provide means of extending such controls using OOJ.
4. They provide a custom Event model.
Thus, developers and architects dealing with decisions on web based delivery should necessarily consider Javascript libraries. Since there are hundreds of them, you should be aware of a few considerations while choosing one:
1. The libraries size matters - prototype.js is small, but UI effects needs libraries like scriptaculous. These can add to the size of the HTTP response - but can be easily managed by web server compression and caching headers. The libraries also come in a "minified" form for deployment.
2. Some of them come with complex controls that you can then extend to create your own. They are proper frameworks. You may choose them based upon your UI needs.
3. Select a library that has a popular user base. JQuery, Dojo, scriptaculous, mooTools, and the now-popular ext-js all have a good user base. Do NOT expect, though, very high level documentation.
All of these libraries provide services such as:
1. Cross-browser DHTML
2. Ajax
3. Common Controls such as trees, accordion
4. Drag and Drop and other effects that work cross-browser
5. JSON and XML support

So, if you are considering an internal or external facing website consider Javascript programming using one of these libraries. It makes life a lot simpler. You gain all of the services by including the necessary javascript files in your header.
(Also knowing one of these libraries provides a fast path to knowing others).

To start exploring, download one of these libraries and go through the tutorials. It does not take much time to figure out (particularly if you know OOJ).

Labels: , , ,