AJAX Developement Model

Wednesday, September 30, 2009

AJAX Development Model
We will see how AJAX development is done by adopting client centric and server centric model.




Client side page lifecycle
The client side lifecycle of a web page is made up by three stages called init, load and unload. When each stage is entered, Sys.Application fires the corresponding event (init, load or unload).

Client Framework :-
Type System
The goal of the Type System is to introduce familiar object-oriented programming concepts to JavaScript -like classes, inheritance, interfaces and event-handling. In addition, this layer also extends existing JavaScript types. For example, the String and Array types in JavaScript are both extended to provide added functionality and a familiarity to ASP.NET developers. In short, the Type System lays the groundwork for the rest of the Ajax core library.
Components layer
Built on top of the solid foundation that the Type System offers, the Components layer does a lot of the heavy lifting for the core library. Within this layer is support for JSON serialization, network communication, localization, DOM interaction and ASP.NET application services like Authentication and Profile.
Application layer
Similar to the page lifecycle in ASP.NET, this layer provides an event-driven programming model that developers can use to work with DOM elements, components and the lifecycle of an application in the browser.
HTML, JavaScript and Xml-Script
ASP.NET AJAX-enabled web pages are written in HTML, JavaScript and a new xml-based, declarative syntax called xml-script. This provides the developer with more than just one option for authoring client-side code - they can code declaratively with xml-script and imperatively with JavaScript. Elements declared in xmlscript are contained in a new script tag:
ASP.NET AJAX Service Proxies
The client framework offers the ability to call Web Services from JavaScript via a set of client-side proxies that are generated from the server. These proxies can be leveraged much like a Web Reference would in managed .NET code.
Server Framework :-


  • Provide an easy-to-use, highly productive framework: The main objective here is to simplify the efforts of adding Ajax functionality to web applications. This is accomplished essentially by providing a rich client library and a comprehensive set of server controls that are easy to use and integrate into existing applications.
  • Server programming model integration: Server controls provide ASP.NET developers with a familiar paradigm for developing web applications. These controls emit the JavaScript needed to Ajax-enable a page with little effort or knowledge of JavaScript and the XMLHttpRequest object.
  • World-class tools and components: Components and tools built on top of the framework not only extend the framework but also provide the development community with a rich collection of tools to leverage and build upon. This also includes tools for debugging, tracing and profiling.
  • Cross platform support: Support for Internet Explorer, Firefox, Safari and Opera extract away the hassle of dealing with browser differences and discrepancies.
Client Centric Development Model

Presentation tier is driven from the client-script using DHTML and JavaScript
• Smarter and more interactive application is delivered from the server to the browser when the page is first loaded.
• Interaction between the browser application and the server is limited to retrieving only the relevant data necessary to update the page.
• The client-centric model is also ideal for mashups and applications that wish to fully exploit all the features that DHTML has to offer.


Server Centric Development Model


  • The application logic and most of the user interface rationale remains on the server.
  • Incremental changes for the user interface are passed down to the browser application instead of the changes being made from the client-side script.
  • The difference between this model and the traditional model in ASP.NET is that only the portions of the UI that need to be rendered are passed down to the browser application, rather than the whole page.
  • When working with controls like the GridView and Repeater in ASP.NET, the server-centric model offers the simplest and most reliable solution.
UpdatePanel for partial rendering
<asp:UpdatePanel ID="panel1" UpdateMode="Always Conditional" runat="server">
<ContentTemplate>
Partial Rendering
</ContentTemplate>
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="" EventName="click textChanged" />
</Triggers>
</asp:UpdatePanel>

AJAX Control Tool Kit
The “Ajax" Control Toolkit is a collection of samples and components that makes it easier then ever to build and consume rich client-side “Atlas” controls and extenders. The toolkit provides both ready to go samples and a powerful SDK to simplify the creation and re-use of your own custom controls and extenders.
Can be downloaded from
http://ajax.asp.net/

Create your own MS AJAX web site
Download installable at
http://ajax.asp.net/
Open Visual Studio
Navigate to File à New à Web Site
Select “ASP. Net AJAX Enabled Web Site”
Website created with necessary config options.

Smart Client Application Components

Thursday, September 24, 2009

Smart Client Application has major six components.
- Application Shell

- Workspace
- Work Item
- Smart Parts
- Modules
- ProfileCatalog.xml
We will discuss above component in the details.


Application Shell
• The main user interface common to all the dynamically loaded modules is the Shell. Typically a form, it always hosts a root WorkItem, which is the root access to all the services, modules, and WorkItems registered by the modules.

• Derives from the class “FormShellApplication” in the namespace “Microsoft.Practices.CompositeUI.WinForms”.
public class MyApplication : FormShellApplication{}


Workspace
• A workspace is a control that is primarily responsible for holding and displaying Views.
• The Composite UI Application Block includes the following types of workspaces:

- WindowWorkspace
- MdiWorkspace
- TabWorkspace
- DeckWorkspace
- ZoneWorkspace

• The Workspace class has functions for :

- Displaying a View
- Hiding a View
- Activating a View
- Closing a View

WorkItem
• A WorkItem is a class encapsulating all the logic required for a use case.

• Technically, it's a container that contains all the required objects such as views and their presenters or controllers, state and commands.
• A CAB application has a tree of WorkItems. The Application Shell contains a reference to the root WorkItem. Given a WorkItem, you can go up one level to its ParentWorkItem, or down to the next level by accessing the workItem.WorkItems collection.

• A WorkItem also contains various other collections.
It has collections of:
- Workspaces
- SmartParts
- Commands
- EventTopics
- Services
- Items

Smart Part

• SmartParts are the visual components of the application. They are hosted by a Workspace.
• You can create SmartParts by simply customizing a standard user control. All you have to do to make a control a SmartPart is to mark the class with the [SmartPart] attribute.

[SmartPart]
public partial class MySmartPart : UserControl
• They are designed to be pluggable and reusable within the same or other applications.
SmartsParts communicate and cooperate between themselves by publishing and subscribing to events.


Modules
• A module is a collection of components (Work Items, services, and so forth) that are needed when performing a certain task.

• You can separate areas of your application into different modules to be able to deploy them to different users or applications.
• When one module has a dependency on another module, you express the dependency with the ModuleDependency attribute.
The CAB will load modules based on the contents of the ProfileCatalog.xml file.

Profile Catalog.xml
• Tells CAB what modules your app has

• Your application will not load a module that is not listed!
<solutionprofile xmlns="http://schemas.microsoft.com/pag/cab-profile">
<modules>
<moduleinfo assemblyfile="CABDemo.Inbox.dll">
<moduleinfo assemblyfile="CABDemo.Calendar.dll">
</modules>
</solutionprofile>

Programming Guidelines

Sunday, September 20, 2009

Following are the standard programming coding guidelines one should follow while developing the application.
Architecture Guidelines

- We should try to use the multi tier architecture which helps in developing application more feasible.
- We should have database class layer which communicates to the database and helps in support and migration of the DB easily.
- We should use the try-catch block to handle all the database exceptions and we can throw the exception into another layer of the application and do take the proper action.
- We should have group all the utility classes into the separate class assemblies.
ASP.NET Session Guidelines
- We should use session variable only within classes only using System.Web.HttpContext.CurrentSession.
- We should store large object in session which might take more memory if number of users are very high on the application.
- We should use the style sheet for standard look and feel of the web pages.It will be help in consistent look of the application.

Coding Guidlines - Naming Convention

Monday, September 14, 2009

Following are naming conventions one should follow as best practice during the development of the application.
- We should use Pascal case for giving name to Classes. E.g. public class EmployeeDetails
- We should use Pascal case for method names E.g. int EmployeeSalary(int empId) { }
- We should use Camel case for declaring the variables. E.g. int totalSalary = 0;
- We should add the prefix “I” for giving name to interface with Camel Case E.g IEmployeeEntity
- We should not use Hungarian notation for declaring the variables instead we should use came casing. We should not use abbreviations also. E.g. string address and not string add
- We should avoid giving single character name for variable. E.g. i, n.
- We should avoid adding underscore for local or temporary variables.

How ClickOnce deployment works?

Thursday, September 10, 2009

Overview
· ClickOnce is a deployment mechanism of the .NET framework application.
· It allows automatic update and deployment from the server side.
· For deployment of the application we need to publish it on the deployment server and provide the link to the system users.
· When users run the application through the given link, the application will be automatically deployed and stored in client computer and it runs.
Deployment Modes
There are two deployment modes of ClickOnce.
1-Installed
2-Online
Installed = In the installed mode the application is still available even though the client machine is in offline mode. The application can be launch through the programs section in the start menu.
Online = In online mode the application will be run through the URL of the deployment server. In this case client machine must be connected to the deployment sever.

ClickOnce runtime is used for automatic updates on client machine.

ClickOnce Deployment Architecture is as below
- First user has to publish the application through the ClickOnce deployment which will generate deployment manifest and application manifest.
- Deployment manifest =It has information related to publication like deployment server URL, the update policy and references of the application manifest etc.
- Application manifest = It has list of application files which are needs to be deployed on client machine.

Smart Client Overview

Monday, September 7, 2009

Smart Client Definition
A Smart Client is an application that uses local resources, utilizes XML Web Services and can be deployed and updated from a centralized server.
It can work both in the connected and disconnected modes.
Smart Client combines the best features found in both the thin and thick architectures.
Smart Client includes following features from the think and thick architectures.

Thick Application
• Rich User Experience
• Offline Capable
• High Developer productivity
• Flexible
Thin Application
• Easy to update
• Easy to deploy
• Easy to manage

Smart Client Features
Local Resource Utilization – A smart client may take advantage of the local CPU, local memory or disk, or any local devices connected to the client
Connected – The application interacts with a number of Web services that provide access to data or an application
Offline Capable – Because they are running on the local machine, one of the key benefits that smart client applications offer is that they can be made to work even when the user is not connected. Intelligent
Install and Update – Applications can be updated while running and can be deployed on demand by clicking on a URL.

Disadvantage of Smart Client
• The MSIL EXE gets downloaded at client side. So it takes more time to load at the first time
• Since MSIL EXE gets downloaded at client there is risk of client "de-compiling" your code
• There is no central control on the application once it gets deployed to the users.

Types of Smart Client Application
• Windows Smart Client applications - These kinds of applications typically use Windows Forms to provide a familiar Windows-style user interface
•Office Smart Client applications - With an Office smart client solution, one can integrate data sources, accessed through Web services, with the features of Word 2003, Excel 2003, InfoPath 2003, or other Office applications.
•Mobile Smart Client applications - Mobile smart clients are applications that run on smart devices — Pocket PCs, Smart phones, etc. These applications are developed using the .NET Compact Framework, which is a subset of the full .NET Framework.

 
 
 
Your Ad Here