Wednesday, June 24, 2009

Gear it up – Web applications go offline

Gears is an exciting addition to web application development strategies. It opens a new dimension for web applications. Gears is an open source browser extension which extends the functionality of a browser and enables web developers create applications which can work offline. Gears does this with the help of three core modules LocalServer, LocalDatabase and WorkerPool.

A local server is used to cache web application resources such as html pages, images etc. to enable the application work in offline mode. Local database allows the developer to retrieve/store data locally on the user’s computer while working offline. This database can then be synchronized with the remote database while working online. Worker thread pool allows heavy duty operations in the background making the application more responsive.

The architecture of Gears is such that it allows the developer to write code which rather than contacting remote database directly works with an intermediate object which can be considered as Data Switch. This object can then figure out whether to retrieve the data from a local database or contact remote database for latest information. The developer can choose to develop the application as either Model or Modeless. In Model applications users can choose to work online/offline whereas in Modeless it happens seamlessly in the background. The developer can also choose to enable certain features of the application work offline while making certain feature work only online as those features might require updated data. The data synchronization can also be done either manually, letting the user specify when to synchronize or it may happen in the background without user’s intervention.

Gears do implement security features as well. It requires user’s permission to allow Gears to be able to make the applications work offline as Gears allow the developers to write the content on user’s machine. Also, the applications can access the databases created by that application and capture urls from the same origin. It is still in consideration to allow applications from other origins to access resources of different origins.

Though Gears is a beta release yet and considered to be a developer only release, you may find some samples on It would be nice to see how exciting applications can be developed with Gears.

Tuesday, June 16, 2009

Getting Started with Flex – for .Net Developers

Though I would not recommend, but if you really want to do a comparison then you can compare Flex with ASP.Net. Like ASP.Net, Flex is also used to develop Rich Internet Application. Apart from the file format and programming language, the other main difference would be that ASP.Net runs at server and can access server side resources directly but Flex works only on client side and has no access to server side resources such as databases directly. However, Flex applications can access the resources such as images, xml files without any server side scripting.

.Net developers who want to learn Flex would be at ease in one aspect that Flex has similar IDE for development (if you are using Flex Builder) as you use in Visual Studio. Just like .Net, Flex development is also comprised of using controls and programming them if required. The difference is in the programming language. You will be using action script 3 for writing business logics.

I will be repeating some of the text from my previous post ‘Getting Started with Flex – for Flash Developers’ as this is applicable to .Net developers as well. In Flex, there are two ways of developing an application, MXML or/and ActionScript 3. MXML is an xml based language developed by Macromedia before Adobe Systems acquired Macromedia. There is no official meaning for the acronym MXML, but the backronym used by some developers is “Magic eXtensible Markup Language”. MXML is primarily used to layout the application interface (which can be done in Design View of Flex builder which eventually generates MXML tags). However, MXML can also be used to write business logic or application behavior for small applications. MXML can be used in conjunction with Action Script to write complex business logic for the applications. It gives an opportunity to a person with not very strong in programming background to be able to develop RIA with ease.

Developers can create their own controls in MXML or Action Script to write the business logics or application behaviors. Unlike ASP.Net in which the output is html, the output of a Flex application is SWF which is targeted to Flash Player 9 or above. Flex has some effects and transitions which can be used to create cool interfaces. One can also extend and create his own effects in Flex.

As I said earlier Flex applications run on client side and have no direct access to database resources or other resources which are not allowed to be accessed by client applications. However, Flex applications do have a way to connect with such type server side resources with the help of Web Services or Remote Procedure Calls. As you are coming from .Net background, you can use .Net to write Web Services and access them in Flex to provide dynamic data.

Application development in Flex can be done by using free open source Flex SDK or Flex Builder 3 (Flex 3 is the latest version of Flex and the next version will be called Gumbo) Software provided by Adobe. Flex Builder can help a developer accelerate application development. If you are looking forward to develop RIA in Flex, there are many nice books available along with the resources/tutorials provided on Adobe site. Some of the books you may consider are McGraw Hill’s ‘Flex 3 A Beginners Guide’ or ‘The Essential Guide to Flex 3’ by friends of ED.

Happy Learning…