Jatin kacha's Blog

Archive for December 2009

I came across an interesting set of principles that you might want to keep
in mind the next time you set out to design an application, a website, or even
improve your daily life. They are The Laws of Simplicity
and were conceived by John Maeda, an artist and noted computer scientist from
the MIT Media Lab. He compiled them in a short, 100-page book (and posted them
on his website as well). I found them in a back issue of Wired
magazine, in an article that applied them in
a critique some new gadget. I have since found that they increasingly
influence my own analysis of UIs and websites, and occassionally
use them as the basis for discussions with clients to keep a design
session on track.

The Laws are:

1. Reduce – The simplest way to achieve simplicity is through
thoughtful reduction of functionality.

2. Organize – Organization makes a system of many appear fewer.

3. Time – Savings in time feel like simplicity.

4. Learn – Knowledge makes everything simpler.

5. Differences – Simplicity and complexity need each other.

6. Context – What lies in the periphery of simplicity is de?nitely not peripheral.

7. Emotion – More emotions are better than less.

8. Trust – In simplicity we trust.

9. Failure – Some things can never be made simple.

10. The One – Simplicity is about subtracting the obvious, and adding the

You can find a more detailed explanation of each law on his site


ASP.NET Development

Performance Improvement

Among the 95% of the .NET developers that said they are
using some flavor of Ajax either in production, development or prototype, the
most used AJAX Framework is ASP.NET AJAX, with 73,7%, followed by the Ajax
Control Toolkit which is used by almost half of the .NET developer that are
using Ajax.

However ASP.NET AJAX model is showing performance problem.
The web application developed in ASP.NET AJAX makes the site slow down.

So following are the few of guideline which will help you
out to improve performance of ASP.NET AJAX application. This will basically
apply to the ASP.NET AJAX version 1.0 final release.

  1. Use HttpWatch to check the network traffic.
    1. This is one of important tool using which you can check the data returned by
      the server. There is dedicated tool available for this. Moreover to that
      you can also utilize Firebux extension of firefox to watch network
      traffic. The dedicated tool is available for the download from following
      URL: http://www.httpwatch.com/download/.

      This is a limited feature version.

  2. Use “ScriptReferenceProfile” to show Javascript reference
    1. ScriptReferenceProfiler is an open source tool on CodePlex, for analysis the JavaScript
      references of ASP.NET AJAX, we can simply add the following code to our
      page in order to show the JavaScript references imported by

      <microsoft:scriptreferenceprofiler runat=“server”>


You can obtain it from the following URL

Reference: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=13356

  1. Web.Config Optimization
    1. To have optimized web.config file our application, all we need to do is to
      have a compression and caching is enabled in web.config file for the
      ASP.NET AJAX Includes. You can use the following code in web.config file
      to enable compression & caching for AJAX includes.



      <scriptResourceHandler enableCompression=“true” enableCaching=“true”/>



      Also check before and after result of before and after of enabling
      caching & compression in network traffic.

      Now this is limited to the compression and caching for AJAX includes. In our site we also
      generally have many other script files included. There can also be no. of
      different CSS files, JS files etc. We can also compress them so that It make fewer request in bytes.

      Basically there is no any method available in ASP.NET which allows the
      compression of JS & CSS files. We need to do it manually and
      reference those compressed file in our application.

      One very key important point to consider is related to change management
      of those files. Once you have compressed file in place and referenced in
      your different pages, If your JS file or CSS
      file need to have any modification, then you again have to recompress it
      from newer version.

      So this method should be adopted for such scripts or CSS which are less
      frequently changed.

      There are different tools available which allows your script and CSS file
      compression. Following are the different methods which can be used for
      this purpose.

      1) Yahoo compresser (http://yui.2clics.net/)

      2) http://www.vlead.in/resources/tools/minify-javascript/index.php
      (The best one which I utilized)

  2. Optimization of ScriptManager
    1. The ScriptManager control manages client script for AJAX-enabled ASP.NET Web
      pages. By default, the ScriptManager control registers the script for the
      Microsoft AJAX Library with the page. This enables client script to use
      the type system extensions and to support features such as partial-page
      rendering and Web-service calls. Following, we need to setting
      the property of ScriptManager to optimize the performance of ASP.NET

Set “scriptMode” to Release.

for e.g.

<asp:ScriptManager ID=”ScriptManager1″
runat=”server” ScriptMode=”Release”>


Moreover to this set “debug” mode in “compilation” section of web.config file
to false.

Disable partial page rendering

If we using the UpdatePanel in the page, we must set this property to true,
conversely, if the UpdatePanel is not using in our page, it would be better
that we set the EnablePartialRendering to false.

For e.g.

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”


  1. Move All Script Tags After Body Content
    1. ASP.NET ScriptManager control has a property “LoadScriptsBeforeUI”, when set to
      false, should load all AJAX
      framework scripts after the content of the page. But it does not
      effectively push down all scripts after the content. Some framework
      scripts, extender scripts and other scripts registered by Ajax Control
      Toolkit still load before the page content loads.

So these are the basic general guidelines which can be
followed one by one to have an improved ASP.NET AJAX response.

for ASP.NET Application Performance

Following, I will demonstrate some of important guideline
for the improvement of ASP.NET application. These guidelines should be
implemented carefully by taking into consideration of development needs. It is
not necessary to have all following steps followed.

  1. Removing unnecessary HTTP MODUES from site.
    1. There are several ASP.NET default HttpModules which
      sit in the request pipeline and intercept each and every request.

      For example, if you aren’t using Membership and Profile provider, you
      don’t need “FormsAuthentication” module. If you aren’t using Windows
      Authentication for your users, you don’t need “WindowsAuthentication”.

      We can remove those unnecessary references of HTTP modules from
      web.config using <remove> tag.

      Generally following are the HTTP modules which are not generally used in
      our current development architecture.

      <remove name=”WindowsAuthentication” />

      <remove name=”PassportAuthentication” />

      <remove name=”AnonymousIdentification” />

      <remove name=”UrlAuthorization” />

      <remove name=”FileAuthorization” />

  2. Removing or compressing “VIEWSTATE” from page
    1. We can override few of method of default System.Web.UI.Page class of .net

      Use the following file and include it in your project’s APP_CODE.
      Inherits rest of all your pages from this page instead of regular System.Web.UI.Page

      Ref: BasePage.vb

  3. Use caching for pages which changes less frequently
    1. There are several ways to use the cache; we’ll focus on the easiest tricks to
      get you started, then point you toward some resources that will help you
      tackle more advanced ways to utilize the cache.

      The simplest solution is to use the OutputCache directive on your pages
      or user controls.

  4. Disable VIEWSTATE for pages where no Grid related functionality.
    1. One should set the VIEWSTATE disabled in those pages where there is no grid
      level manipulation. When we have a simple page with no complex logic, it
      should be disabled.

      Moreover to that set the following pages which are not security

      1) EnableViewStateMac=”false”

      2) ViewStateEncryptionMode=”never”

  5. Use classical ASP type of page for normal pages.
    1. Another important point is to use a classical ASP type of pages which are simple.
      Those pages which do not have any complex display should be developed
      like normal ASP pages. Please check the following referenced page for
      this similar purpose.

      these are such files which do not have underlying code behind file
      attached to it.

      We can also utilize the feature of “include” file method which is there
      in classical ASP.

for structuring ASP.NET Application

In the following, I will demonstrate the basic guidelines
for the structuring of any web application.

See these guidelines are generally be best suitable for SEO
oriented sites. It can also be adopted for general site also keeping
requirement in mind.

These guidelines are prepared keeping modularized
development in mind. So there are no such tricks that by following them you
will be able to better structure your site. One should do the do modularized
development in their programming also to achieve this.

  1. Use dedicated folders for JS & CSS files.In a site generally there are different JS & CSS files for different
    functionality. These JS & CSS files should be accordingly structure
    inside your website. Please take a look at the following example for the
    better illustration of this method.

    Say for e.g. in a site few pages have functionality to display a jQuery
    zoom light box when anyone click on the image of product.

    So following should be the structure of JS & CSS files.

    In this example, assume there are also few global JS & CSS. So I will
    also demonstrate the purpose of integrating them in site.



    | |___lightbox

    | |___lightbox.js





    | |___lighbox

    | |___ lighbox.css



    This modularization can also be used to
    differentiate CSS & JS for each page of site.

    Modularization is also not limited to the CSS & JS files, one can
    follow same modularization concept across different type of files also
    like XML content, flash content, image folders etc.

  2. Use proper naming conversion in CSS files.
    1. Care full design of CSS classes and attributes provide better traceability. As
      you just shown above that the CSS & JS can be modularized. We should
      also use proper naming convention in those CSS file. If you follow these
      conventions, you can easily identify respective class.

      Say for e.g.

      you set naming abbreviation of respective CSS as per below.

      1) global.css
      = glb

      2) lightbox.css = lg

      so now you can have following CSS class/section defined in respective css

      like in global.css






      color: #7D3D0D;

      font-family: Arial;

      font-size: 20px;

      font-weight: normal;

      text-decoration: none;

      clear: both;


      in the same way, you can also different class in lighbox.css



      width: 100%;

      margin: 20px 10px 10px 10px;




      width: 700px;

      height: 600px;


  3. Configure
    APP_CODE to have two sub directories. Each sub directory can be used for
    different language. It is generally like following.



    Respective programming files should be placed in respective folders. Also
    make sure to configure code sub directory in web.config also.

before final release of site

Following, there are some important and necessary checks
that web-sites should be checked against before the official launch.

  1. Favicon
    1. A favicon icon the tab or window in which your website is open in the
      user’s browser. It is also saved with the bookmark so that users can
      easily identify pages from your website.

      for e.g.

      <link href=”images/fav_icon.ico” rel=”icon”
      type=”image/Jpeg” />

  2. Title & Meta data
    1. Your page title is the most important element for SEO and is also important so
      that users know what’s on the page. Make sure it changes on every page
      and relates to that page’s content.

      Also one should make sure that related meta data
      details are also get placed in every pages and are changes as it should
      be to different pages.

  3. Cross-Browser Check
    1. The most popular browsers to check are Internet Explorer 6, 7 and 8, Firefox
      3, Safari 3. Following are the few methods used to do cross browser check

      1) XecoCode (http://www.xenocode.com/browsers/)

      2) IETester (http://www.my-debugbar.com/wiki/IETester/HomePage)

      3) Browser shot (http://browsershots.org/)

  4. Links
    1. Don’t just assume all your links work. Click on them. You may often forget to
      add “http://” to links to external websites. There may be case when some
      URL rewriting related prefix or postfix would be forgotten.

Getting dig into SQL CLR

SQL CLR is a new SQL Server feature that allows you to embed logic written in C#, VB.Net, and other managed code into the body of T-SQL objects like stored procedures, functions, triggers, aggregates and types. Client applications interact with these resulting routines like they are written in native T-SQL. Internally, things like string manipulations and complex calculations become easier to program because you are no longer restricted to using T-SQL and now have access to structured .Net languages and the reuse of base class libraries. Externally, the logic you create is wrapped in T-SQL prototypes so that the client application is not aware of the implementation details. This is advantageous because you can employ SQL CLR where you need it without rearchitecting your existing client code.

With SQL CLR, you are also freed from the constraint of logic that applies only within the context of the database. You can with appropriate permissions write logic to read and write to file systems, use logic contained in external COM or .Net DLLs. These capabilities are exciting and concerning, especially in the historical context of new feature overuse. To help you use this new feature appropriately, we want to make sure that you understand how it integrates with SQL Server and where this feature may be heading. In this chapter, we’ll give you this type of overview. We’ll spend the rest of the book explaining these concepts using real-world SQL CLR examples that you can use today.

Let’s go through step by step for your first introduction on sql clr.

The first step in creating a stored procedure (or any database object) is to create a SQL Server project in Visual Studio:

  • From the File menu, create a new project
  • In the New Project Dialog, select and expand a language node in the Project Types area
  • Select the Database node
  • Select the SQL Server Project template
  • Click OK and you are done

Next you will be promted of of creating sql connection to connect to sql server. But wait, before that your datebase and server need to be configured to run/host SQL CLR.

If you dont know how to do that just run the following code in your query window

sp_configure ‘clr enabled’, 1




Creating your first user defined CLR function

  • Open an existing SQL Server Project, or create a new one. From the Project menu, select Add New Item.
  • Select User Defined Function
  • Type a Name for the new user defined function.
  • Add code to run when the function is executed.
  • In the following code snippet, i have written a custom user defined SQL CLR function which convert the european anccented characters into regular english character.

public partial class UserDefinedFunctions


[Microsoft.SqlServer.Server.SqlFunction( DataAccess = DataAccessKind.None, Name = "fnReplaceAccentedCharacters", IsDeterministic = true)] public static SqlString fnReplaceAccentedCharacters(SqlString inputString)


SqlString xReturnValue="";

Int16 a;

String[,] xCharGroup ={{"à", "a"}, {"â", "a"}, {"ä", "a"}, {"é", "e"}, {"è", "e"}, {"ê", "e"}, {"ë", "e"}, {"î", "i"}, {"ï", "i"}, {"ô", "o"}, {"ö", "o"}, {"û", "u"}, {"ü", "u"}, {"ù", "u"}, {"ç", "c"}, {"œ", "oe"}, {"Œ", "oe"}, {" ", "-"}};

for (a = 0; a < xCharGroup.GetLongLength(0); a++)

inputString = ((String)inputString).Replace(xCharGroup[a, 0], xCharGroup[a, 1]);

return (xReturnValue=inputString);



Once the code is ready, you can build and deploy the code to the database by pressing ‘F5’.

To test the deployment, there is a file in your project called test.sql. In this file, you can add script calls to the obects you just created. For example, to call the function created above, enter: Select dbo.fnReplaceAccentedCharacters(‘des objets de très grande qualité, originaux, épurés,’)

That’s it. If the stored procedure was written correctly, you will now see this item in list of functions in your management stuidio. However, you’ll see the object has a lock icon next to it, as shown below. This is because the object is not editable outside of the Visual Studio project.

Beginning with WordPress, A wordpress tutorial

WordPress is like the best blogging software, If you want to do it the easy way, you can always start a blog by going to WordPress.com
and signing up.

The other option is actually purchasing web-space, installing WordPress in the purchased web space, and setting up your “self-hosted” WordPress blog.

Either way you choose to go, if you are new to WordPress, you have some things to learn before getting too far. For instance, what are widgets? Sidebars? Headers and footers? For veteran bloggers, these terms are second nature but for a newbie (please don’t be offended at the term), they have to learn.

Enter video WordPress tutorials! I love being able to help people get started with new technology. I just recently helped out a few friends with WordPress sites and it was a blast. I did a video tutorial or two but what I found out was that much of my work wasn’t really needed! When I ran into WordPress.tv, a site with some of the best WordPress tutorials out there, I almost fell over!

is a very well-done site full of tutorials showing you how to do everything from managing widgets to adding Twitter updates to your sidebar to adding a Paypal button to you blog! Now if I want to show someone how to do something, I can either record a screencast for them and figure out how to share it with them OR I can head over to WordPress.tv and see if it’s something that’s already covered, saving me much time and effort!

It’s really that easy. As you’ll be able to tell when you browse the site, they have tutorials for novices and the more experienced. I think you’ll be pleased by what you find at WordPress.tv.

My tweets