Monday, 26 March 2012

NoSQL with RavenDB

RavenDB is the latest addition to the NoSQL and document database world. RavenDB is an Open Source (with a commercial option) document database for the .NET/Windows platform developed  by Ayende Rahien.  Raven stores schema-less JSON documents, allow you to define indexes using Linq queries and focus on low latency and high performance. RavenDB is .NET focused document database which comes with a fully functional .NET client API  and supports LINQ. RavenDB comes with two components, a server and a client API. RavenDB is a REST based system, so you can write your own HTTP cleint API. As a .NET developer, RavenDB is becoming my favorite document database. Unlike other document databases, RavenDB is supports transactions using System.Transactions. Also it's supports both embedded and server mode of database. You can access RavenDB site at http://ravendb.net

A demo App with ASP.NET MVC

Let's create a simple demo app with RavenDB and ASP.NET MVC. To work with RavenDB, do the following steps.

  1. Go to http://ravendb.net/download and download the latest build.
  2. Unzip the downloaded file.
  3. Go to the /Server directory and run the RavenDB.exe. This will start the RavenDB server listening on localhost:8080

You can change the port of RavenDB  by modifying the "Raven/Port" appSetting value in the RavenDB.exe.config file.
When running the RavenDB, it will automatically create a database in the /Data directory. You can change the directory name data by modifying "Raven/DataDirt" appSetting value in the RavenDB.exe.config file.

RavenDB provides a browser based admin tool. When the Raven server is running, You can be access the browser based admin tool and view and edit documents and index using your browser admin tool. The web admin tool available at http://localhost:8080
The below is the some screen shots of web admin tool

 



Working with ASP.NET MVC 
To working with RavenDB in our demo ASP.NET MVC application, do the following steps
Step 1 - Add reference to Raven Cleint API
In our ASP.NET MVC application, Add a reference to the Raven.Client.Lightweight.dll from the Client directory.
Step 2 - Create DocumentStore

The document store would be created once per application. Let's create a DocumentStore on application start-up in the Global.asax.cs.


documentStore = new DocumentStore { Url = "http://localhost:8080/" };
documentStore.Initialise();

The above code will create a Raven DB document store and will be listening the server locahost at port 8080   
Step 3 - Create DocumentSession on BeginRequest  
Let's create a DocumentSession on BeginRequest event in the Global.asax.cs. We are using the document session for every unit of work. In our demo app, every HTTP request would be a single Unit of Work (UoW).
BeginRequest += (sender, args) =>
  HttpContext.Current.Items[RavenSessionKey] = documentStore.OpenSession();

Step 4 - Destroy the DocumentSession on EndRequest

EndRequest += (o, eventArgs) =>
{
    var disposable = HttpContext.Current.Items[RavenSessionKey] as IDisposable;
    if (disposable != null)
        disposable.Dispose();
};

At the end of HTTP request, we are destroying the DocumentSession  object.
The below  code block shown all the code in the Global.asax.cs

private const string RavenSessionKey = "RavenMVC.Session";
private static DocumentStore documentStore;

protected void Application_Start()
{
//Create a DocumentStore in Application_Start
//DocumentStore should be created once per application and stored as a singleton.
documentStore = new DocumentStore { Url = "http://localhost:8080/" };
documentStore.Initialise();
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
//DI using Unity 2.0
ConfigureUnity();
}

public MvcApplication()
{
//Create a DocumentSession on BeginRequest  
//create a document session for every unit of work
BeginRequest += (sender, args) =>
    HttpContext.Current.Items[RavenSessionKey] = documentStore.OpenSession();
//Destroy the DocumentSession on EndRequest
EndRequest += (o, eventArgs) =>
{
var disposable = HttpContext.Current.Items[RavenSessionKey] as IDisposable;
if (disposable != null)
disposable.Dispose();
};
}

//Getting the current DocumentSession
public static IDocumentSession CurrentSession
{
  get { return (IDocumentSession)HttpContext.Current.Items[RavenSessionKey]; }
}

We have setup all necessary code in the Global.asax.cs for working with RavenDB. For our demo app,
Let’s write a domain class

public class Category
{

    public string Id { get; set; }

    [Required(ErrorMessage = "Name Required")]
    [StringLength(25, ErrorMessage = "Must be less than 25 characters")]
    public string Name { get; set;}
    public string Description { get; set; }  

}

We have created simple domain entity Category. Let's create repository class for performing CRUD operations against our domain entity Category.

public interface ICategoryRepository
{
    Category Load(string id);
    IEnumerable<Category> GetCategories();
    void Save(Category category);
    void Delete(string id);      
}


public class CategoryRepository : ICategoryRepository
{
    private IDocumentSession session;
   
    public CategoryRepository(IDocumentSession session)
    {
     this.session = session;
    }
    //Load category based on Id
    public Category Load(string id)
    {
        return session.Load<Category>(id);
    }
    //Get all categories
    public IEnumerable<Category> GetCategories()
    {
        var categories= session.LuceneQuery<Category>()
            .ToArray();
        return categories;

    }
    //Insert/Update category
    public void Save(Category category)
    {
       
     //store category object into session
     session.Store(category);   
    //save changes
     session.SaveChanges();
    }
    //delete a category
    public void Delete(string id)
    {
        var category = Load(id);
        session.Delete<Category>(category);
        session.SaveChanges();
    }       
}

For every CRUD operations, we are taking the current document session object from HttpContext object.
session = MvcApplication.CurrentSession;
We are calling the static method CurrentSession from the Global.asax.cs
public static IDocumentSession CurrentSession
{
    get { return (IDocumentSession)HttpContext.Current.Items[RavenSessionKey]; }
}

Retrieve Entities 
The Load method get the single Category object based on the Id. RavenDB is working based on the REST principles and the Id would be like categories/1. The Id would be created by automatically when a new object is inserted to the document store. The REST uri categories/1 represents a single category object with Id representation of 1.  
public Category Load(string id)
{
   return session.Load<Category>(id);
}
The GetCategories method returns all the categories calling the session.LuceneQuery method. RavenDB is using a lucen query syntax for querying. I will explain more details about querying and indexing in my future posts.  
public IEnumerable<Category> GetCategories()
{
    var categories= session.LuceneQuery<Category>()    
        .WaitForNonStaleResults()
        .ToArray();
    return categories;

}
Insert/Update entity
For insert/Update a Category entity, we have created Save method in repository class. The Save mothod used for both insert and update category. We just need to store category object on the document session. The session.SaveChanges() will save the changes to document store. if the category is a new one, it will insert a new record and update the category object, if it is an existing category object.
public void Save(Category category)
{
//store category object into session
session.Store(category); 
//save changes           
session.SaveChanges();
}

Delete Entity 
In the Delete method, we call the document session's delete method and call the SaveChanges method to reflect changes in the document store. 
public void Delete(string id)
{
    var category = Load(id);
    session.Delete<Category>(category);
    session.SaveChanges();
}

Let’s create ASP.NET MVC controller and controller actions for handling CRUD operations for the domain class Category
 
public class CategoryController : Controller
{
private ICategoryRepository categoyRepository;
//DI enabled constructor
public CategoryController(ICategoryRepository categoyRepository)
{
    this.categoyRepository = categoyRepository;
}
public ActionResult Index()
{  

    var categories = categoyRepository.GetCategories();
    if (categories == null)
        return RedirectToAction("Create");
    return View(categories);
}

[HttpGet]
public ActionResult Edit(string id)
{
    var category = categoyRepository.Load(id);    
    return View("Save",category);
}
// GET: /Category/Create
[HttpGet]
public ActionResult Create()
{
    var category = new Category();
    return View("Save", category);
}
[HttpPost]
public ActionResult Save(Category category)
{
    if (!ModelState.IsValid)
    {
        return View("Save", category);
    }

        categoyRepository.Save(category);
        return RedirectToAction("Index");


}       
[HttpPost]
public ActionResult Delete(string id)
{
    categoyRepository.Delete(id);
    var categories = categoyRepository.GetCategories();
    return PartialView("CategoryList", categories);   

}       
}

RavenDB is an awesome document database and many examples are available in codeplex.

Sunday, 18 March 2012

jQuery Mobile

Touch-Optimized Web Framework for Smartphones & Tablets

A unified, HTML5-based user interface system for all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design.


Seriously cross-platform with HTML5

jQuery mobile framework takes the "write less, do more" mantra to the next level: Instead of writing unique apps for each mobile device or OS, the jQuery mobile framework allows you to design a single highly-branded web site or application that will work on all popular smartphone, tablet, and desktop platforms. Device support

jQuery Mobile 1.0.1 Supported Platforms

jQuery Mobile has broad support for the vast majority of all modern desktop, smartphone, tablet, and e-reader platforms. In addition, feature phones and older browsers are supported because of our progressive enhancement approach. We’re very proud of our commitment to universal accessibility through our broad support for all popular platforms.
We use a 3-level graded platform support system: A (full), B (full minus Ajax), C (basic). The visual fidelity of the experience is highly dependent on the CSS rendering capabilities of the device and platform so not all A grade experience will be pixel-perfect but that’s the nature of the web.

A-grade – Full enhanced experience with Ajax-based animated page transitions.

  • Apple iOS 3.2-5.0 - Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3), original iPhone (3.1), iPhone 3 (3.2), 3GS (4.3), 4 (4.3 / 5.0), and 4S (5.0)
  • Android 2.1-2.3 – Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
  • Android 3.1 (Honeycomb)  – Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
  • Android 4.0 (ICS)  – Since it’s very new, we don’t have a test phone in our lab but early reports are positive. Note: transitions can be poor on upgraded devices
  • Windows Phone 7-7.5 – Tested on the HTC Surround (7.0) HTC Trophy (7.5), LG-E900 (7.5), Nokia Lumia 800
  • Blackberry 6.0 – Tested on the Torch 9800 and Style 9670
  • Blackberry 7 – Tested on BlackBerry® Torch 9810
  • Blackberry Playbook (1.0-2.0) – Tested on PlayBook
  • Palm WebOS (1.4-2.0) – Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0)
  • Palm WebOS 3.0 – Tested on HP TouchPad
  • Firebox Mobile (10 Beta) – Tested on Android 2.3 device
  • Skyfire 4.1 - Tested on Android 2.3 device
  • Opera Mobile 11.5: Tested on Android 2.3
  • Meego 1.2 – Tested on Nokia 950 and N9
  • Samsung bada 2.0 – Tested on a Samsung Wave 3, Dolphin browser
  • UC Browser – Tested on Android 2.3 device
  • Kindle 3 and Fire - Tested on the built-in WebKit browser for each
  • Nook Color 1.4.1 – Tested on original Nook Color, not Nook Tablet
  • Chrome Desktop 11-17 - Tested on OS X 10.6.7 and Windows 7
  • Firefox Desktop 4-9 – Tested on OS X 10.6.7 and Windows 7
  • Internet Explorer 7-9 – Tested on Windows XP, Vista and 7
  • Opera Desktop 10-11 - Tested on OS X 10.6.7 and Windows 7

B-grade – Enhanced experience except without Ajax navigation features.

  • Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
  • Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
  • Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)

C-grade – Basic, non-enhanced HTML experience that is still functional

  • Blackberry 4.x - Tested on the Curve 8330
  • Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
  • All older smartphone platforms and featurephones – Any device that doesn’t support media queries will receive the basic, C grade experience

WURFL in ASP.NET Applications

An application that uses WURFL is simply an application that needs to check a number of effective browser capabilities in order to decide what to serve.  The WURFL database contains information about a huge number of devices and mobile browsers. This information essentially consists in a list of over 500 capabilities. Each device, uniquely identified by its user-agent string (UAS), falls into a group and inherits the capabilities defined for the group, plus the delta of base capabilities that make it unique.
Programming a WURFL-based application is therefore a fairly easy task. All you need to do is loading WURFL data in memory and query for specific capabilities you’re interested in for the currently requesting browser/device. Let’s step into some more details for an ASP.NET Web Forms application. (If you’re using ASP.NET MVC, don’t panic—it’s exactly the same.)

Loading WURFL Data

WURFL data changes over time but it’s not certainly real time data. So you can blissfully load all of it at the startup of the application and keep it cached for as long as you feel comfortable. When an update is released, you just replace the data and restart the application. Both programming and deployment aspects of the operation are under your total control.
In an ASP.NET application, the Application_Start method is the place where you perform all one-off initialization work. Here’s how you can instruct the method to load and cache WURFL data.  
public class Global : HttpApplication
{
   
public const String WurflManagerCacheKey = "__WurflManager";
   
public const String WurflDataFilePath = "~/App_Data/wurfl-latest.zip";
    public const String WurflPatchFilePath = "~/App_Data/web_browsers_patch.xml";
    private void Application_Start(Object sender, EventArgs e)
    {
       
var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath);
        var wurflPatchFile = HttpContext.Current.Server.MapPath(WurflPatchFilePath);
        var configurer = new InMemoryConfigurer()
                .MainFile(wurflDataFile)
                .PatchFile(wurflPatchFile);
        var manager = WURFLManagerBuilder.Build(configurer);
        HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
    }
}
You can specify multiple patch files by simply calling the PatchFile method multiple times in the same chained expression.
var configurer = new InMemoryConfigurer()
                .MainFile(wurflDataFile)
                .PatchFile(wurflPatchFile1)
                .PatchFile(wurflPatchFile2);
As you can see, both file names and cache details are under your control. You might want to maintain a copy of the WURFL data on your Web server. The API doesn’t currently support reading from other than local files. You can also specify the WURFL data files in the web.config file. In this case, you replace the call to InMemoryConfigurer with ApplicationConfigurer.
var configurer = new ApplicationConfigurer();
The web.config section has to look like below:
<wurfl>
   <mainFile path="..." />   <patches>
     
<patch path="..." />
     :
 
</patches>
</
wurfl>
Note that the <wurfl> section is a user-defined section and needs be registered before use with the .NET infrastructure. For this reason, you also need to add the following at the top of the web.config file:



&lt;br&gt;&amp;amp;lt;configuration&amp;amp;gt;&lt;br&gt; &amp;amp;lt;configSections&amp;amp;gt;&lt;br&gt; &amp;amp;lt;section name="wurfl" &lt;br&gt;type="WURFL.Config.WURFLConfigurationSection,wurfl" /&amp;amp;gt;&lt;br&gt; &amp;amp;lt;/configSections&amp;amp;gt;&lt;br&gt; :&lt;br&gt;&amp;amp;lt;/configuration&amp;amp;gt;&lt;br&gt; Caching WURFL Data
In Web applications, it is always a good habit to cache any large and constant block of data; WURFL data is no exception. To cache data in ASP.NET applications, you typically use the native Cache object. WURFL doesn’t mandate any special guideline as far as caching is concerned. You are completely free of determining the name of the key used to retrieve the data. Likewise, it is up to you to implement caching and expiration policies. For example, you can make cached WURFL data dependent on the timestamp of the wurfl_latest.zip file and/or patch files. In this way, cached data is automatically cleared when you replace the WURFL file. For more information on using cache dependencies in ASP.NET, have a look at Programming ASP.NET 4”, Dino Esposito, Microsoft Press.
To be precise, you never cache raw data but you cache, instead, a reference to the object that owns that data. The object you cache is the WURFL manager. This is also the object you query for capabilities. Here’s how you retrieve the cached instance of the manager.
var wurflManager = HttpContext.Current.Cache[WurflManagerCacheKey] as IWURFLManager;
It goes without saying that you should check the instance for nullness as there’s no guarantee that the reference is still there when you try to access it. A good practice is checking whether the instance is null and reload it as appropriate. Another alternative is not using the (otherwise recommended) Cache object, but stick to the Application object which still keeps its content global to all sessions but doesn’t implement any scavenging policies.

Refactoring Your Code Just a Bit

You don’t actually need much code to initialize WURFL; but this is not an excuse to keep it quite simplistic. The sample applications for both ASP.NET Web Forms and ASP.NET MVC use a helper class that encapsulate much of the required logic and contain some additional features such as auto-reload of WURFL data in case the ASP.NET cache is cleared.
In particular, you might want to add the WurflLoader.cs file to your project and rewrite the startup code as follows:
private void Application_Start(Object sender, EventArgs e)
{
    WurflLoader.Start();  
}
The WurflLoader class has another static method through which you retrieve the instance of the WURFL manager to use for your queries. The method is GetManager and all it does is retrieving and returning the WURFL manager instance from the cache. If the instance is null, it then automatically creates and caches new one. Here’s the source code:
public static IWURFLManager GetManager()
{
    return GetManager(HttpContext.Current);
}
public static IWURFLManager GetManager(HttpContext context)
{
    var wurflManager = context.Cache[WurflManagerCacheKey] as IWURFLManager;
    if (wurflManager == null)
        return InitializeWurflManager(context, _wurflDataPath, _wurflPatchFilePath);
    return wurflManager;
}
The WurflLoader class is self-contained and has no dependencies on other files, except the WURFL binaries.

Querying for Capabilities

Once you hold a WURFL Manager object in your hands, you’re pretty much done. A WURFL manager is an object that implements the IWURFLManager interface.
public interface IWURFLManager
{
    IDevice GetDeviceForRequest(WURFLRequest wurflRequest);
   
IDevice GetDeviceForRequest(string userAgent);
   
IDevice GetDeviceForRequest(HttpRequest httpRequest);
    IDevice GetDeviceById(string deviceId);
    ICollection<IDevice> GetAllDevices();
}
The class offers a few methods for you to gain access to the in-memory representation of the detected device model. You can query for a device in a variety of ways: passing the ASP.NET HttpRequest object, the user agent string, the device ID, or a WURFL specific request object. The WURFL specific request object —the class WURFLRequest—is merely an aggregate of data that includes the user agent string and profile.
All of the methods on the WURFL manager class return an IDevice object which represents the matched device model. The interface has the following structure:
public interface IDevice
{
   string Id { get; }
   string UserAgent { get; }
   string GetCapability(string name);
   IDictionary<string, string> GetCapabilities();
}
You can check the value of a specific capability through the following code:
var is_tablet = device.GetCapability("is_tablet");
If you call the GetCapabilities method you get a dictionary of name/value pairs. The value associated with a capability is always expressed as a string even when it logically represents a number or a Boolean.
Armed with capabilities—WURFL supports more than 500 different capabilities—you are ready to apply the multi-serving pattern to your next ASP.NET mobile Web site.

Summary

The WURFL API currently available for ASP.NET is a rather generic one that works very closely to the metal and doesn’t provide much abstraction. This is good news as it allows developers to fully customize every single aspect of their code interaction with WURFL.  In particular, you can control the caching logic and can easily define your helper classes (like the aforementioned WurflLoader class)  taking into account testability and dependency injection.

Thursday, 15 March 2012

Top 10 JavaScript Frameworks

JavaScript – an indispensable part for developing websites and web pages, whether that is simple pages or professional website, and whether you are senior or junior. Nowadays, JavaScript frameworks become more powerful and more specialized; they can do many things in just a few basic steps.
However, when you decide that you need a JavaScript framework it can be quite a challenge to figure out which framework to should use, which framework is best for your needs, … ? This is mainly because there are so many frameworks out there you can choose from.
In this post, I want to summarize the list of frameworks that Google assumes most popular, maybe you wonder why it’s Google? Because it’s the most popular search engine, so I think the results will be most relevant and accurate to the majority of web developers. Here’s the list of top JavaScript frameworks by Google, with the keyword: “javascript framework”.

1. jQuery: The Write Less, Do More, JavaScript Library

jQuery: The Write Less, Do More, JavaScript Library
Yes, jQuery is really a new kind of JavaScript library, you can write less but do more; maybe jQuery is the JavaScript framework that have the biggest collection of plug-ins and add-ons. Some things you should know:

  • Current version: 1.3.2
  • Size: 19 KB (Minified and Gzipped) and 120 KB (Uncompressed Code)
  • Author: John Resig
  • Tutorials in 19 languages: 183 (data on 19 October, 2009)
  • Sites in use: 1000+
  • Plugins: 3.493 (data on 19 October, 2009)
  • Easy to learn
  • Support designers very well, by using CSS syntax
  • A lots of nice and lovely extensions
  • Great community, maybe largest
  • Used by millions of website and well known companies like Google, DELL, CBS, NBC, DIGG, Bank og America, WordPress, Drupal, Mozilla etc…

2. MooTools – a compact javascript framework

MooTools - a compact=
MooTools is an Open Source MIT application, which you have the possibility to use it and modify it in every circumstance.
  • Current version: 1.2.3
  • Uncompressed Size: 95 KB (client) and 22 KB (server)
  • Author: Valerio Proietti
  • Using: w3c, cnet, bing, …
  • Plugins on Official site: 4
  • Better OOP structure
  • The animations are smoother
  • The syntax and the handle of elements are more logical

3. Prototype: Easy Ajax and DOM manipulation for dynamic web applications

Prototype - Easy Ajax and DOM manipulation for dynamic web applications
Used by the big media companies and organizations, Protorype is unique JavaScript framework that is quickly becoming the codebase of choice for web application developers. And now with the latest version, 1.6.1, Protorype has improved performance, new user-action events, and compatibility with the mordern browsers.

  • Lastest version: 1.6.1 (1st September, 2009)
  • Uncompressed Size: 136 KB (closely 5.000 code lines)
  • Creator: Sam Stephenson
  • Using: NASA, CNN, NBC, …
  • Plugins: 150+
  • Better for the big web apps, give you many choices to write custom code

4. Dojo Toolkit: great experiences for everyone

Dojo - great experiences for everyone
Dojo Core features small, fast, deep – gives you a rich set of utilities for building responsive applications; great interface widgets with accessibility and localization built right in.

  • Lastest version: 1.4 Beta
  • Compressed Size: 26 KB (closely 5.000 code lines)
  • Foundation: Dojo Foundation
  • Dojo Users: AOL, IBM, Sun, …
  • Client-side data storage
  • Server-side data storage
  • Asynchronous communication

5. script.aculo.us: easy-to-use, cross-browser user interface JavaScript libraries

script.aculo.us - easy-to-use, cross-browser user interface JavaScript libraries
Update to the lastest version, script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours, have some improved features as: loading work maker, Windows Media player/RealPlayer checker, fixing old issues, … check more at here

6. ExtJS: Cross-Browser Rich Internet Application Framework

Ext JS - a cross-browser JavaScript library for building rich internet applications
ExtJS is a very cool cross-browser JavaScript framework for helping you build rich web applications, support all modern web browsers. Plus plenty of plugins and extensions, your ExtJS based web applications become more attractive by features such as well designed, documented and extensible Component model, high performance, easy-customizable UI widgets, …

7. UIZE: supporting widgets, AJAX, DOM, templates, and more

UIZE - a powerful, open source, object oriented JavaScript framewor
Some things about UIZE you should know:

- is an open source Javascript framework
- easy-to-change your own CSS skins
- plenty of built-in widgets
- amazing effects and powerfull features

8. YUI Library: is proven, scalable, fast, and robust

YUI is proven, scalable, fast, and robust
YUI
is one of the biggest JavaScript frameworks in this list. YUI has all things to help you build interactive web applications using techniques such as DOM scripting, DHTML and AJAX by a set of powerful utilities and controls. YUI has countless powerful features, plugins, extensions that take you the very long time to learn.

9. Archetype

Archetype JavaScript Framework
Let sees the power of Archetype by yourself to understand what it can do.

  • Lastest version: 0.10.0 (September 2009)
  • Size of package: 2.14 MB
  • Creator: Temsa & Swiip
  • In use: GifTeer, Meteo France, …

10. qooxdoo: the new era of web development

qooxdoo - the new era of web development
What’s qooxdoo? That’s great and powerfull JavaScript framework to create rich internet applications (RIAs) by taking the advantages of object-oriented JavaScript. qooxdoo includes a platform-independent development tool chain, a state-of-the-art GUI toolkit and an advanced client-server communication layer. It is open source under an LGPL/EPL dual license.

Top 10 Mobile JavaScript Frameworks

Creating web apps and sites for the mobile web has its own sets of challenges and techniques. From UIs optimized for fingers instead of mouse cursors to the bandwidth limitations that most portable personal devices have, developing for mobile devices requires a paradigm shift for those of us who’ve traditionally created products aimed at desktops.
To help you rapidly deploy cross-platform mobile apps and websites, there’s a wide range of JavaScript frameworks you can take advantage of.

Some common characteristics of JavaScript mobile web development frameworks:
  • Optimized for touchscreen devices: Fingers as input devices instead of mouse cursors provide an extra set of challenges in user interface design. Mobile web development frameworks provide standard UI elements and event-handling specifically for mobile device platforms.
  • Cross-platform: Support for multiple mobile device platforms such iOS and Android allows you to get your app to a wide range of users.
  • Lightweight: Because of current bandwidth limitations, a stronger emphasis on lowering file weight is placed into mobile web development frameworks.
  • Uses HTML5 and CSS3 standards: Most mainstream mobile devices have web browsers that support HTML5 and CSS3, and so mobile web development frameworks take advantage of new features available in these upcoming W3C specifications for a better user experience.
In this article, you’ll find my top picks of JavaScript mobile web development frameworks you should consider using to build your next mobile web app or website.

1. jQuery Mobile

jQuery Mobile
jQuery Mobile, a framework that will help you rapidly and confidently develop mobile app user interfaces across popular mobile device platforms like iOS and Android, is perhaps the most popular project out there.
The framework boasts a lightweight code base (weighing in at 20KB when minified and gzipped) and a huge bevy of standard user interface elements that mobile device users are accustomed to, such as switches and sliders.
See jQuery Mobile in action by going to its demo page (it doubles as the framework’s official documentation).
If jQuery isn’t your thing, check out MooTools Mobile, a MooTools plugin by MooTools core developer Christoph Pojer and Dojo Mobile, which leverages the Dojo API to help developers rapidly build apps for mobile platforms.

2. Titanium Mobile

Titanium Mobile
This powerful and robust mobile web development framework allows you to use your existing HTML, CSS and JavaScript knowledge to make native-like mobile apps for iOS and Android.
As one of the bigger mobile web development frameworks out there — with over 300 APIs and an active developer community — you know you’ll often find help and support from peer developers.
Titanium Mobile supports native UI elements for iOS and Android like table views, tabs, switches and popovers. It also has features that enable you to interact with the mobile devices’ camera and native file storage system.

3. The-M-Project

The-M-Project
The-M-Project is another solid JavaScript framework that takes advantage of new HTML5 features for easier and better mobile app development.
The framework follows the popular model-view-controller (MVC) software architecture pattern, which is a huge selling point for many developers.
It has offline support so that your users can continue working without an Internet connection (they can then sync up to the server next time they’re online) and excellent documentation (the project has a Getting Started guide for new users of the project).
To witness The-M-Project in action, check out their showcase, which includes items like the ToDo App and KitchenSink (a showcase of all the UI elements included in the framework).

4. Jo

Jo
Jo is a framework aimed at developers working on HTML5-capable mobile devices such as those the use the iOS, webOS, Android and Chrome OS platforms.
It has standard, native-like UI elements such as the web form widget for your login screens and the popup widget that you can use for providing extra information when a user clicks on an interface element.
See the demo page on their site, which includes a screencast displaying Jo in action on multiple devices and mobile platforms.

5. xui.js

xui.js
If you need something super lightweight and you only need features for standard client-side development tasks such as DOM manipulation, event-handling, Ajax and a few animation effects, check out xui.js. xui.js packs a punch in such a tiny package (4.2 KB when gzipped).
xui.js provides targeted builds for specific mobile browsers such as WebKit and IE mobile for when you’re developing apps strictly towards a particular mobile device operating system.

6. EmbedJS

EmbedJS
EmbedJS is a JavaScript framework for embedded devices (which includes mobile phones, TVs, tablets and so forth).
What’s great about EmbedJS is that it has multiple builds for specific platforms and browsers such as iOS, Firefox, Android, etc., which translates to an optimal user experience and less code to serve to your users. And if you’d like to customize your build, the creators provide you with the EmbedJS Build tool.
EmbedJS is based on Dojo, so if you’re familiar with the Dojo API syntax, you’ll be able to use EmbedJS right away.

7. zepto.js

zepto.js
zepto.js is a mobile JavaScript framework built specifically for mobile WebKit browsers (e.g. Safari and Chrome). It prides itself in its minimalist development philosophy, which translates to simplicity for helping developers get stuff done quickly. What’s more is that this JS framework is ultra-lightweight at only 5KB.
The zepto.js syntax borrows from, and is compatible with, jQuery — a welcome plus for many developers.
To learn more about this framework, see developer Thomas Fuchs’ presentation of zepto.js.

8. DHTMLX Touch

DHTMLX Touch
DHTMLX Touch, a free HTML5/JavaScript framework optimized for touchscreen devices, brings you the ability to craft beautiful mobile web apps quickly.
The DHTMLX Touch UI Designer is a visual editor for building mobile user interfaces, and it’ll help you construct top-notch UIs with minimal coding.
Check out samples of DHTMLX Touch in action, which includes a menu app for the iPad (perfect for restaurants) and Book Shop (a proof-of-concept demo for an e-store offering books).

9. Mobilize.js

Mobilize.js
Mobilize.js is a JavaScript framework for porting your existing website to a mobile-friendly version. It’s easy to integrate into your site because it does everything on the client-side, and has facilities for detecting mobile browsers so that you can serve them the mobile version of the site. WordPress users might want to check out the Mobilize.js WordPress plugin.

10. ChocolateChip Mobile

ChocolateChip Mobile
ChocolateChip Mobile is a JavaScript framework developed towards future-forward web browsers. It shares syntax similar to jQuery or Prototype.
The resemblance to jQuery doesn’t stop at the syntax — for example, like jQuery, it can handle events through binding and delegation, and has methods such as .css and .toggleClass.
You can grab ChocolateChip Mobile’s source code off GitHub.

Other JavaScript Libraries for Mobile Web Development

  • jQTouch: a jQuery plugin specifically for Android and iOS devices.
  • jqpad: a web development framework built and optimized for iPad development.
  • iUI: a user interface framework for making iPhone-like web apps.
  • Sencha: an HTML5 mobile web development framework

Top 4 Free Embedded Databases

During the last few days I’ve done a lot of virtual leg-work researching and comparing the various alternatives, trawling through documentation and forums. The results are below. Hopefully, if you’re ever in the same situation, this list will make your life a bit easier.
Of course, the list is far from comprehensive – it wasn’t really my goal to include every embedded database in existance, but rather to find those that fit the needs of the project. The focus was on speed, support for multi-threading and connectivity (what programming language interfaces are available for the DB). I also left out databases that are tied to a single language or framework (Java/.NET)

#1 SQLite

SQLite
Connectivity : Any programming language (almost)
Platforms : Linux, Mac OS X, OS/2, Windows (Win32 and WinCE) and embedded devices
Footprint : 300 Kb (or 180 Kb with optional features ommitted)
Model : Relational (SQL92 with some exceptions)
License : Public domain
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain. Includes both a native C library and a simple command line client for its database.
Highlights :
  • + If you start looking into embedded databases, you won’t be able to make a step without tripping over some SQLite evangelist. This database engine is definitely one of the most popular, so there’s a lot of tutorials for nearly any language available, plus a huge community of users to help you out.
  • + It’s fast, robust and “just works”. Hey, even Firefox uses it.
  • - Referential integrity (i.e. foreign keys) isn’t enforced. However, you can work around this by using triggers.
  • - No ALTER TABLE command and no stored procedures.
  • - Limited support for concurrent access/multi-threading.
  • Column datatypes aren’t enforced – you can store any data of any length in any column. Whether this is a flaw or a benefit really depends on what you want to do with it.
  • #2 Firebird SQL

    Firebird SQL
    Connectivity : .NET, C/C++, Delphi, Java, PHP, Perl, Python, VB, COBOL, etc (see also)
    Platforms : Windows (Win 98 and up), Linux (tricky)
    Footprint : 4-5 MB
    Model : Relational (SQL92 and most of SQL99)
    License : Open source (LGPL)
    Firebird is a relational database offering many ANSI SQL standard features. (…) Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers. It has been used in production systems, under a variety of names, since 1981.
    Highlights :
    • + Referential integrity is supported, which is nice when compared to SQLite.
    • + Concurrency support is also decent.
    • + Supports triggers and stored procedures.
    • - A notably confusing and disjointed website. I had to dig around for a while to find out what I needed to know. Some sections also present outdated information.
    • - No built-in full text search.
    • - If you casually browse around Friebird’s site you may get the impression that the embedded version only works with .NET (they even have an entire sub-website dedicated to the .NET version). However, you can actually use it with many other languages by downloading the embedded version and using the standard Firebird APIs.

    #3 ScimoreDB

    Scimore DB
    Connectivity : C++, .NET, Delphi (discontinued?)
    Platforms : Windows (XP, Vista, Windows Server 2000 – Windows Server 2008)
    Footprint : < 4 MB
    Model : Relational
    License : Free for commercial and non-commercial use
    (There is no quote here because almost everything on the website reads like a shallow advertisement. Nevertheless, the feature list looked attractive enough.)
    Highlights :
  • + ScimoreDB can be used both as an in-process and out-of-process engine, which results in very good concurrency support (at some speed penalty).
  • + Table level and row level locking is supported.
  • + Foreign keys Referential integrity works.
  • - C++ interface is a bit awkward and the Delphi components are apparently in limbo.
  • #4 Oracle Berkley DB

    Berkley DB
    Connectivity : C, C++, Java, Tcl
    Platforms : *nix, Windows, Windows CE, VxWorks, S60, BREW
    Footpring : 400 Kb (minimum)
    Model : Key-value
    License : Open source (dual-licensed)
    Berkeley DB delivers the same robust data storage features as traditional, relational database systems, such as ACID transactions and recovery; locking, multiple processes and multi-threading for high concurrency; hot and cold backup; and single-master replication for high availability applications. Berkeley DB can manage databases in memory, on disk or both.
    Highlights :
  • This is the only item on the list that doesn’t use some form of SQL. Instead, Berkley DB stores key-value pairs. There is no query language.
  • + Thanks to the simple architecture and long history of development, Berkley DB has extremely good scalability and performance.
  • - The key-data database structure may not be suitable for your projects.
  • - Dual licensing means it’s only free if your application is also distributed as open source. If you want to use this embedded database engine in a closed-source, commercial application, you will need to pay licensing fees.
  • In-memory database

    An in-memory database (IMDB; also main memory database system or MMDB) is a database management system that primarily relies on main memory for computer data storage. It is contrasted with database management systems which employ a disk storage mechanism. Main memory databases are faster than disk-optimized databases since the internal optimization algorithms are simpler and execute fewer CPU instructions. Accessing data in memory reduces the I/O reading activity when querying the data which provides faster and more predictable performance than disk. In applications where response time is critical, such as telecommunications network equipment and mobile ads networks, main memory databases are often used.

    Products


    Product name License Description
    Adaptive Server Enterprise (ASE) 15.5 Proprietary enterprise database from Sybase)
    Apache Derby Apache License 2.0 Java RDBMS
    Altibase Proprietary has in-memory and disk table; HYBRID DBMS
    BlackRay GNU General Public Licence (GPLv2) and BSD License
    CSQL GNU General Public Licence or proprietary
    Datablitz Proprietary DBMS
    Eloquera Proprietary In-memory, In-memory:persist modes
    EXASolution Proprietary relational database management system from EXASOL), in-memory query processing, massively parallel data processing, column by column storage
    eXtremeDB commercial product DBMS, also check out its open source PERST dbms.
    Finances Without Problems commercial product primarily in-memory database with hybrid features
    FleetDB MIT NOSQL db with Writing to an append-only log to provide durability.
    H2 Mozilla Public License or Eclipse Public License has a memory-only mode
    HSQLDB BSD license has a memory-only mode
    IBM TM1 Proprietary in-memory BI and data analysis
    InfoZoom Proprietary in-memory BI and data analysis
    KDB Proprietary DBMS, also supports disk based data
    #liveDB Open Source Prevalence engine
    membase Apache License NoSQL, hybrid
    Mercury Proprietary object oriented, in-memory data management with persistency support, in-built compiler, hosts application server on same machine; developed by staila technologies, an ETHZ spinoff
    MicroStrategy in-memory BI for MicroStrategy 9
    MonetDB MonetDB License
    MySQL GNU General Public License or proprietary has a cluster server which uses a main-memory storage engine
    Oracle Berkeley DB Sleepycat License can be configured to run in memory only
    Panorama for Windows and Macintosh, both single user and server versions
    ParAccel Proprietary in-memory, columnar, relational, ACID-compliant; disk-based mode as well
    Polyhedra IMDB Proprietary relational, supports High-Availability; acquired in 2001 by ENEA
    QlikView BI-tool developed by QlikTech
    RDM Embedded Proprietary including hybrid
    RDM Server Proprietary including hybrid
    Redis BSD NoSQL Advanced key-value store with support for hashes, lists, sets, and sorted sets.
    solidDB by IBM including hybrid, HSB-based HA, Shared memory, embedded, XA, etc.
    SAP HANA database Proprietary Database engine of the SAP In-Memory Appliance (SAP HANA) produced by SAP AG
    SQLite Public domain hybrid, RAM and disk dbs can be used together
    Starcounter in-memory object relational dbms
    Tarantool BSD NoSQL, extendable with Lua stored procedures
    TimesTen by Oracle in memory only or as a cache for Oracle Database
    Vertipaq Proprietary Microsoft PowerPivot and Microsoft Analysis Services in-memory BI engine
    VoltDB GNU General Public License v3 in-memory
    WebDNA WebDNA Software Corporation hybrid specifically designed for server-side database-driven websites - freeware
    TREX search engine in the SAP NetWeaver integrated technology platform produced by SAP AG
    Xcelerix by Frontex commercial product
    WX2 by Kognitio commercial product
    Xeround commercial product, database as a service, in-memory infrastructure with MySQL front-end