Galin Iliev's blog

Software Architecture & Development

ASP.NET Adjust HTML Size, UX and AJAX

Problem Introduction

You come up with a great HTML layout for data-driven ASP.NET web page which makes perfect sense from business perspective and reveals key indicators while making possible to drilldown into details if needed. This page utilizes DHTML and AJAX calls to improve User eXperience (UX) and overall page looks great until… your database is not filled up and page load time is increasing due to generated HTML size, DHTML is slow due to big DOM tree and users starting to complain about it.

Possible Solutions

At that point there are several approaches that can be employed to help:

  1. Rework page layout so only part of data is loaded;
  2. Download data to the client in XML or JSON format and generate necessary HTML code on client
  3. Load only those portions that need to be immediately displayed and load others on demand (e.g. like paging)

Let’s explore these options:

Rework layout

Here is no technical challenge here – just business one: you have to sell new layout to existing users/customers and once they liked the initial one this can be really difficult. If you can do that – go ahead. There is nothing wrong with that approach.

Client-side bindings

Instead of downloading 10 MB HTML code to client’s browser you can generate pure JSON and having a template of HTML just to fill data in the HTML template with simple (or not-so-simple) loop. Good news here is that such feature is coming to ASP.NET AJAX in v4.0. It is called client templates and implements the idea. Here are some resources:

Partially Loading Page

This is also not new concept – load only  those parts that should be visible immediately to the user. Traditional paging explores that option although it is not that fancy. If you’re using Google Reader you probably noticed that it loads only visible part of the feed and as you scroll down it keeps loading from the RSS feed.

So here is the idea: having small piece of HTML loaded would ease the browser in rendering HTML DOM tree and you gain performance. As user keeps using the page you keep adding HTML to existing DOM tree by loading it dynamically using AJAX.

Tricky part could be rendering ASP.NET User Control within Web Service so pure HTML can be returned by AJAX. Here are some useful tips:

Summary

Utilizing these techniques could improve download time for your web apps and also speed them up because the browser doesn’t need to process whole DOM before give the control to the user. All these can be used together or in any combination as long as it makes sense from business perspective.

Hope this helps!

Playing Poker - Planning Poker

Imaging the following situation: your team is having a meeting in which you have to decide which features, components to build for next product or service release. Or by having a specification from system analyst you have to decide how long it would take to build the desired product so appropriate offer can be made to the client.

Either way it is very important what you will decide because all future changes will be around this very first decision. You are setting the expectations and this is very important for the project outcome.

One very popular technique is asking the developers for their estimation. Once the team leader has this number it multiplies x2 and gives it to PM. PM also multiplies it x2.5 so there will be good buffer zones. This approach, funny or not, somewhere works. And there are happy customers and ISV.

Yesterday I attended Seattle code camp and  a very interesting session was “Agile Estimation Techniques” presented by David Starr.

crispdeck (image by old.crisp.se)
The idea is simple: everyone from the team has a deck of cards. Having once already solved problem/built feature by the team is set as base one at well-known cost (in man-days, man-hours, ). Then another upcoming tasks is put on the table and after initial discussion everyone of the team lay the card of choice representing their thinking of the cost.
If there are big difference if some team members’ choice let them discuss their choice and repeat until everyone pick closer costs.

Look interesting, doesn’t it?! Read more here:

Managing Humans: Biting and Humorous Tales of a Software Engineering Manager

ManagingHumans  "What you're holding in your hands in by far the most brilliant book about managing software teams you're ever going to find. If you’re in a bookstore, buy it immediately, take it home, and read it right now. If you’ve found this book on a friend bookshelf, steal it immediately. You don’t have time to get to a bookstore, and you can always make new friends later."
Joel Spolsky, cofounder and CEO of Fog Creek Software

Fortunately I didn’t have to spoil any friendship and I was able to borrow the book from corporate library. With a series of tales Michael Lopp introduces the reader into the world of the tech manager. Whether manager or just wannabe this book describes very interesting situations and cases which can benefit you in so many ways. If you haven’t been in such situation yet you can mentally prepare for it and have an idea of good action in the back of your head when one occurs.

Ability to be in someone’s shoes is so rare and combined with good writing skills creates a wonderful must-have book.

This book is really so interesting so I am going to read it in just two days…

VS2008 Web Setup Project and Win2008

I had interesting experience today. I tried to create a web setup project for one of my recent projects. As you know it is pretty straightforward: From Visual Studio 2008 File –> Add –> New Project –> Select Setup wizard.

image  

and just add output from existing project.
Then press Ctrl+Shift+B (Build ) and you’re ready… But not in Windows Server 2008. When I decided to test this newly made installation package I hit the ground with single dialog showing this message:

"The installer was interrupted before ApplicationName could be installed. You need to restart the installer to try again.

Click "Close" to exit."

 

Being experienced installer package developer I knew what I had to do: run the installer with verbose logging.

by executing this line:

   1: msiexec /i Installer.msi /lv detail.log

And I had nice 57 KB  file to read in wonderful notepad. And the problem action quickly appeared:

   1: Action start 16:22:53: WEBCA_SetTARGETSITE.
   2: MSI (c) (B4:4C) [16:22:53:082]: Note: 1: 2235 2:  3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'WEBCA_SetTARGETSITE' 
   3: MSI (c) (B4:48) [16:22:53:082]: Invoking remote custom action. DLL: C:\Users\ADMINI~1\AppData\Local\Temp\MSIFB61.tmp, Entrypoint: SetTARGETSITE
   4: INFO   : [11/11/2008 16:22:53:097] [SetTARGETSITE                           ]: Custom Action is starting...
   5: INFO   : [11/11/2008 16:22:53:097] [SetTARGETSITE                           ]: CoInitializeEx - COM initialization Apartment Threaded...
   6: ERROR  : [11/11/2008 16:22:53:097] [SetTARGETSITE                           ]: FAILED:    -2147221164
   7: ERROR  : [11/11/2008 16:22:53:097] [SetTARGETSITE                           ]: Custom Action failed with code: '340'
   8: INFO   : [11/11/2008 16:22:53:097] [SetTARGETSITE                           ]: Custom Action completed with return code: '340'
   9: Action ended 16:22:53: WEBCA_SetTARGETSITE. Return value 3.
  10: MSI (c) (B4:4C) [16:22:53:097]: Doing action: FatalErrorForm
  11: Action start 16:22:53: FatalErrorForm.

Seeing WEBCA_SetTARGETSITE means that the installer was trying to set the destination. Having a web setup this means IIS was asked for “Default Web Site” and this call must be the one that fails. But why!? I have Web Server Role installed on the machine:

image

I and remembered from my MS DevDays 2008 IIS talk  – you still can use old (pre v7) IIS management tools with IIS7 as long as you have “IIS 6 Metabase Compatibility” role service installed.

image

I installed this role and … Voila!!! it works!!!