Saturday 11 October 2014

Single-page application (SPA) – Introduction

 

A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience to web application like desktop application.

In a SPA, either all necessary code – HTML, JavaScript, and CSS – is retrieved with a single page load, or the appropriate resources are dynamically loaded and added to the page as necessary, usually in response to user actions. The page does not reload at any point in the process, nor does control transfer to another page, although modern web technologies (such as those included in HTML5) can provide the perception and navigability of separate logical pages in the application. Interaction with the single page application often involves dynamic communication with the web server behind the scenes.

The term single-page application was coined by Steve Yen in 2005, though the concept was discussed at least as early as 2003 and several working examples of thin client desktop solutions over HTTP on the market as early as 2000. Prior to the advent of the XMLHTTPRequest object standard, hidden frames were used to transmit data asynchronously out of the view of the end user.

Modern browsers that can parse HTML5 allow developers to shift the UI and application logic from web servers to the client. Mature open-source libraries support building of SPA without digging too deep into JavaScript trenches and fighting with technology problems.

There are few distinct characteristics of the professional Single Page Application:

  • Chunking – the web page is constructed by loading chunks of HTML fragments and JSON data instead of receiving full HTML from a web server on every request. (Backbone.js, pjax, jQuery, Upshot.js)
  • Controllers – JavaScript code that handles complex DOM and data manipulations, application logic and AJAX calls is replaced by controllers that separate views and models using MVC or MVVM patterns. (Backbone.js, Knockout.js, JavascriptMVC)
  • Templating – coding of UI and DOM manipulations are replaced by declarative binding of data to HTML templates. (Knockout.js, Mustache, jQuery Templates, Underscore.js)
  • Routing – selection of views and navigation (without page reloads) that preserves page state, elements and data (History.js, Crossroads.js, Backbone.js, pjax, HTML5 History API)
  • Real-time communication – two-way communication of a client application and web server replaces one-way requests from a browser (HTML5 Web Sockets, Socket.io, SignalR)
  • Local storage – capabilities of storing data on a browser for performance and offline access replace cookies and intensive data loads from web server (HTML5 Local storage).

 

Modern web applications: An overview of SPA

This is hard to do with other approaches. Supporting rich interactions with multiple components on a page means that those components have many more intermediate states (e.g. menu open, menu item X selected, menu item Y selected, menu item clicked). Server-side rendering is hard to implement for all the intermediate states - small view states do not map well to URLs.

Single page apps are distinguished by their ability to redraw any part of the UI without requiring a server round trip to retrieve HTML. This is achieved by separating the data from the presentation of data by having a model layer that handles data and a view layer that reads from the models.

 

image

 

 

 

 

Example of Building SPA in MVC .NET Framework

 

 

image

 

 

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

HTML Style of SPA

 

image

 

image

 

image

 

 

 

MVC Style of SPA

 

image

 

 

image

 

Result of both the approaches

image

 

 

 

 

Modules in Angular.js

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

image

 

 

 

 

Handling Data in Angular.js

image

 

 

image

 

 

image

 

 

 

image

 

 

 

Filtering on View of Angular.js

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Blogger Labels: Single,Introduction,interface,goal,user,HTML,JavaScript,resources,response,technologies,perception,Interaction,communication,server,Steve,concept,examples,client,solutions,Prior,advent,XMLHTTPRequest,data,Modern,developers,logic,servers,Mature,libraries,trenches,technology,characteristics,Page,Application,JSON,Upshot,Controllers,AJAX,MVVM,Knockout,JavascriptMVC,templates,Mustache,selection,navigation,History,Crossroads,Real,Sockets,Socket,SignalR,Local,storage,capabilities,performance,overview,interactions,components,menu,item,URLs,presentation,layer,Example,Framework,Style,Result,Modules,Angular,View,desktop,pjax,jQuery,browser

Friday 28 March 2014

LINQ Architecture

 

 

LINQ - Beyond Queries

 

image

 

 

image

 

 

image

 

 

 

Using Named Parameters

image

 

 

image

 

 

image

 

 

 

Using Extension Methods

 

image

 

 

image

 

 

 

Fluent APIs

 

image

 

 

 

A Validation Scenario

 

Legacy Validation Technique

image

 

 

image

 

 

New Validation Technique

image

 

 

 

Functional Validation

 

image

 

 

 

A More Complex Scenario

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Using Expressions

 

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

 

Data Access with LINQ In Layered Applications

 

image

 

 

 

image

 

 

 

The Demo Application

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

 

 

IUnitOfWork and IObjectSet

 

image

 

 

image

 

 

image

 

 

 

IUnitOfWork and IRepository

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

Composable Queries

 

image

 

 

 

As IEnumerable LINQ Query

 

image

 

 

image

 

 

image

 

 

image

 

Note:  Above query operation issue the bear query against SQL server as it is IEnumerable.  All the TOP and Order by clause will be handled in IN MEMORY operation.

 

 

 

As IQueriable LINQ Query

image

 

 

image

 

Note:  Above query operation issue the query against SQL server with TOP and Order by clauses as it is IQueriable.  All the TOP and Order by clause will be handled in IN SQL Server level.

 

 

image

 

 

 

Laziness

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

image

 

 

 

image

 

 

image

 

 

image

 

 

 

Blogger Labels: LINQ,Architecture,Beyond,Queries,Parameters,Extension,Methods,Fluent,APIs,Validation,Scenario,Legacy,Technique,Functional,Complex,Expressions,Data,Applications,Demo,Application,IUnitOfWork,IObjectSet,IRepository,Composable,IEnumerable,Query,Note,Above,server,Order,clause,MEMORY,IQueriable,clauses