Galin Iliev's blog

Software Architecture & Development

Was this information helpful?

Outlook Recently I got the error message and with a smile remembered the funny video showing how developers in Microsoft really shares the users’ pain.

I knew what to do (after saving draft message):
Plan A: Restart outlook and try again.
Plan B: Use Outlook Web Access

But will typical user know what to do without lose data?!

Then I remembered how good error messages are built: they should contain three parts. No less because it cannot provide full information. No more because user is overwhelmed. Exactly three:

  1. Describe what happened – first part briefly describes what went wrong.
  2. Give directions what to fix – user might really know what to fix. It could be just overlooked. Tell them what to change to fix the problem. Even program/PC restart is a solution.
  3. What next?! What if the problem still persist?! – If we are here then the problem is serious. And the user have tried basic scenarios to fix and can call someone for help without feeling stupid/guilty that don’t know how to fix the problem.

On other hand this is extremely useful message:

image

P.S. Plan A did the job :)

Application Architecture Guide 2.0

“To deal with the many technology additions since then, J. D. Meier and his team from Microsoft patterns & practices have created a new application architecture guide to provide insightful guidance for designing .NET applications based on the latest practices and technologies. The outcome is Application Architecture Guide 2.0, a guide targeted to help solution architects and developers design effective applications on the .NET platform. The guide gives an overview of the Microsoft .NET platform and the main technologies and capabilities within it. It provides not only principles-based guidance, but also platform-independent, pattern-oriented guidance for designing your application. Even though the guide itself is comprehensive on its own, the team has also provided a Knowledge Base on the Web, which provides informative expansion on the topics and concepts outlined in the guide.”

Forewords by Scott Guthrie
Corporate Vice President of .NET Developer Platform
Microsoft

Go grab it or read online @ http://www.codeplex.com/AppArchGuide/

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!

.NET External Configuration & Build Process

It is very good practice to have several environments when creating a software solution - typical environments are Development -> Integration -> Staging -> Production environments. Also having Automated Continuous Integration server like CruiseControl.NET can greatly improve teamwork and quality of developed solution. Of course having a solution build (by CruiseControl.NET) you might want to have the installation project also build... and you will need a deployment procedure so the steps would look like these:

  1. Check-in source code changes
  2. Trigger a build on CI build server for the solution
  3. Trigger a build on CI build server for the build package
  4. Execute publish script which will deploy binaries to certain environment/servers and will change app settings, connection strings etc.

Example project setup can be seen on Omar Al Zabir's blog post ASP.NET website Continuous Integration+Deployment using CruiseControl.NET, Subversion, MSBuild and Robocopy.

 

Of course having all changes for different environments in publish script would make it big and difficult to maintain. This is why it is better to keep all environment/servers specific settings outside of the project. One option is machine.config. And storing it in source control, of course.

 

Another option is having all those settings in separate folder. I wasn’t aware of this option of .NET Configuration API and I was disappointed  when I found that XInclude is not supported. Fortunately there configSource section attribute which allows to achieve same functionality. For some ( more here ) this might be well known but I found this recently and AFAIK it is not widely used.

 

So you can specify web.config/app.config file like this:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <configuration>
   3:   <connectionStrings configSource="ConnectionStrings.config" ></connectionStrings>
   4:   <appSettings configSource="settings.config"></appSettings>
   5: </configuration>

and then specify actual configuration in external files. Here are my examples for ConnectionStrings.config

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <connectionStrings>
   3:   <add name="cs1" connectionString="Data Source=myServerAddress;Failover Partner=myMirrorServer;Initial Catalog=myDataBase;Integrated Security=True;"/>
   4: </connectionStrings>

and Settings.config

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <appSettings>
   3:   <add key="s1" value="Some very important setting"/>
   4: </appSettings>

 

As you can see from example the only important thing is to have root element of external file named same as referenced section in the core config file.

and after that you can simply get the values as usual:

   1: class Program
   2: {
   3:     static void Main(string[] args)
   4:     {
   5:         Console.WriteLine("cs1: {0}", ConfigurationManager.ConnectionStrings["cs1"].ConnectionString);
   6:         Console.WriteLine("s1: {0}", ConfigurationManager.AppSettings["s1"]);
   7:         Console.ReadLine();
   8:     }
   9: }

 

This means you can refactor configuration of existing .NET applications without having to touch the code or even recompile. Just be careful :)

Happy XML/Config refactoring :) !

VS2008 seminars in New Horizons Bulgaria

Yesterday was last seminar from VS2008 series held in the New Horizons Bulgaria office with Microsoft Bulgaria support.

The seminars was very interesting (not only from my perspective of trainer) but also from audience perspective we see in their feedback. During high demand I am publishing presentations and demo scripts where available. It is always good to write code in live (although not very easy - try it ;) ) and this is why I cannot provide working demos - I have only my own cheat lists which I use in cse I am stuck somewhere.

Deep Dive in LINQ - Here I talked about new features in C# in details and how they are build internally(also described in my Introduction in LINQ and C# 3.0 (In Bulgarian) ). Also I covered LINQ to SQL, LINQ to XML.  In demos we took a look at C# syntax sugar, new ways to work with XML as well as some problems stated in Project Euler and solved with C# 3.0. Slides + Demo scripts (PPTX+DOCX - 1.22MB)

Develop Dynamic Web Sites with ASP.NET 3.5 - This session was focused on web development. Here I show new controls to work with LINQ to SQL data source declaratively. We took a look at ASP.NET Extensions (aka Futures): ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET AJAX Integration, ADO.NET Data Services. All features was shown in code except ADO.NET Data Services. For ASP.NET AJAX was shown how to control Browser's Back Button from both server-side and client-side. Slides+Demo Scripts (PPTX+DOCX - 3.23 MB).

Overview of WCF, WF, WPF - Although these technologies are not new there is still some improvements in .NET 3.5. These components are very useful but their adoption is not very fast. We talked about the architectural decisions and challenges behind them. The demos show how to work with WCF in VS2008, How to create REST Service and how to expose JSON as result. WF demos show how to create simple sequential workflow. WPF demo presented project structure, generated code, XAML (of course) and WPF data binding basics. Slides+Demo Scripts (PPTX+DOCS - 10.8 MB).

Hope you'll find it useful.
As always any comments and feedback are very welcome.

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta

There is no doubt that VS 2008 and .NET 3.5  totally rocks! ScottGu's division keeps pushing these products and constantly improving developer's productivity and shortening development cycle.

This time MS is preparing to release .NET 3.5 SP1 and VS 2008 SP1 releases.

In short here are improvements:

Improvements for Client Development
  • ASP.NET Data Scaffolding Support (ASP.NET Dynamic Data)
  • SP.NET Routing Engine (System.Web.Routing)
  • ASP.NET AJAX Back/Forward Button History Support
  • ASP.NET AJAX Script Combining Support - Omar Al Zabir wrote an extensive article about this approach.
  • Visual Studio 2008 Performance Improvements HTML Designer and HTML Source Editor
  • Visual Studio 2008 JavaScript Script Formatting and Code Preferences
  • Better Visual Studio Javascript Intellisense for Multiple Javascript/AJAX Frameworks - who can blame MS that force us to use their JS framework now?!
  • Visual Studio Refactoring Support for WCF Services in ASP.NET Projects
  • Visual Studio Support for Classic ASP Intellisense and Debugging - I am wondering when this technology will be declared dead :) (This is what I used in my first web apps too :))
Improvements for Client Development
  • Application Startup and Working Set Performance Improvements
  • New .NET Framework Client Profile Setup Package
  • New .NET Framework Setup Bootstrapper for Client Applications
  • ClickOnce Client Application Deployment Improvements
  • Windows Forms Controls
  • WPF Performance Improvements
  • WPF Data Improvements
  • WPF Extensible Shader Effects
  • WPF Interoperability with Direct3D
VS 2008 for WPF Improvements
  • Several performance improvements
  • Events tab support within the property browser
  • Ability to sort properties alphabetically in the property browser
  • Margin snaplines which makes form layout much quicker
  • Better designer support for TabControl, Expander, and Grid
  • Code initiated refactoring now updates your XAML (including both control declarations and event declarations in XAML)
  • Go to Definition and Find All References now support things declared in XAML
Data Development Improvements
  • SQL 2008 Support
  • ADO.NET Entity Framework and LINQ to Entities
  • ADO.NET Data Services
WCF Development Improvements
  • Significant scalability improvements (5-10x) in Web-hosted application scenarios
  • Support for using ADO.NET Entity Framework entities in WCF contracts
  • API usability improvements with DataContract Serializers, and with the UriTemplate and WCF web programming models
  • Enhanced TestClient support within VS 2008 SP1
  • New Hosting Wizard in VS 2008 SP1 for WCF Service Projects
  • Improved debugging support in partial trust scenarios
VB and C# Improvements !!!
Team Foundation Server Improvements

Pretty impressive...

Read full novel by Scott Guthrie here :)

Release package is settled: Entity Framework &amp; ADO.NET Data Services in VS 2008 SP1 and .NET 3.5 SP1

It's settled! The Entity Framework (and the Entity Designer) along with ADO.NET Data Services will RTM as part of the Visual Studio 2008 and .NET 3.5 SP1 releases!

Unfortunately, we don't have official release dates at this point, but stay tuned. You'll also want to keep an eye out for the upcoming SP1 Beta 1, which will be your next chance to check out updated bits for both of these products.

Elisa Flasko
Program Manager, Data Programmability

(via this ADO.NET team blog post)

VS2008 and .NET 3.5 (WCF, WPF, WF) Training Kit

Microsoft released a nice training kit for the latest technologies that will help you to become a real hero very quickly.

This package is a real treasure because it covers a bunch of technologies:

  • C# 3.0
  • VB 9.0
  • LINQ
  • WPF
  • WCF
  • WF
  • Silverlight
  • ASP.NET
  • AJAX
  • CardSpace
  • Mobile
  • Visual Studio Tools for Office
  • Visual Studio Team System
  • Application Lifecycle Management
image

And the materials are of the different types:

  • Presentation - will be very helpful to prepare talks for community
  • Demos
  • Labs - very helpful to walk through new technologies in deep.

Go grab it!