Subversion

I have been really drawn towards subversion (svn) for the past couple of days and have been reading documentation on it like crazy. There are two ways in which you can install subversion, one with Berkley DB (BDB) and the other with Fast Secure File System (FSFS). From all the reading I have done I figured that FSFS is a better option than BDB. The problem is that most blogs and forums I have read talk about svn 1.3, whereas with 1.4 they have made some big changes. In any case I will stick with FSFS until I hear otherwise.

The two big questions I had coming from a VSS background was how do we add new users to the source control system. I could not find an answer anywhere on the Internet, so I assumed that the default was windows authentication. The other question I had was how svn handled versioning. I found answers to both questions in a free book on subversion. The versioning answer is a bit long so I would suggest you read chapter 4 in the book. I didn't like the authentication answer but you can read it in chapter 6 of the book. Basically there is a file named svnserve.conf in the conf folder of your repository in this file you can set the password-db attribute to the name of the file that holds usernames and passwords. The content of the file is clear text so anyone that has access to the server can see your password. I also came across another material that shows how to enable windows authentication, but all that is through Apache, so IIS users are out of luck.

On a different note, I am really getting pissed at not being able to add new tags on the fly when I am writing blog entries. When I designed and implemented the blogging engine, I left that ability to phase II which never came (sounds familiar eh!). Anyways, I will fix it in the coming days, that will give me the oppurtunity to play with Atlas a little more heh!


Interesting Stuff

Application Domains in .NET explained
Another blog resource on TDD

.NET file format
AJAX and DHTML best practices

A practical guide to seven agile methodologies part 1
The tao of Agile


Bookmarks

Bookmarks for future reference
Continuous Integration writeup
Continuous Integration Server
Subversion popular open source version control software
Perforce fairly popular paid version control software


Maintenance vs Performance

On my routine article search on Test Driven Development TDD, I came across Jeremy D. Miller's blog. I found this article of his to be a good list of todo items for any one starting on a new project. A couple of other good articles of his are here and here.


Regular Expressions simplified

I have been relying on regular expressions a lot lately and there is one tool without which the job would have been very difficult. The tool is The Regulator. It is simply an awesome tool. You enter the input string and then start writing your regular expression, as you do it, you can keep testing the expression to see whether it works / tweak it. Once satisfied you can copy the expression into your code and be sure for it to work.

Well the maker of The Regulator has come out with a new even simpler tool. It's named Regulazy. As the name suggests, you don't have to write the regular expression anymore, just highlight the information that you want to be part of the regular expression, right mouse and click one of the options and the tool writes the expression for you. That simple.
Enjoy!


HTTP Compression

I serve my website off of my home computer which has a decent broadband connection. The upload speed however is a mere 384KB, which used to make my web pages slow in loading up until I enabled HTTP compression and let me tell you it is a real blessing. Not only does it save a lot of bandwidth, but more importantly my pages are a lot more responsive.

Most modern browsers support two compression algorithms, GZip and Deflate. I am using Blowery an open source compression software for serving my web pages in Deflate compression mode. The other thing I enabled last week on my site was AJAX using the new Microsoft Atlas Framework. What I saw was that one of the JavaScript files served to the browser was a whopping 242KB. Although script files get cached by the browser, the speed on the first serving on my web page would be aweful.

The Javascript files are served through a new concept in ASP.NET called Web Resources, where you can embed JavaScript and image files directly into your assembly as resources. When the ASP.NET engine gets a request for these resources it extracts these files out of the assembly and serves them. The file that does is called WebResource.axd. I don't have a clue as to what that file is / does, but I will do some reasearch to find out. The point is that by enabling Blowery the JavaScripts on my web pages stop working. I found a patch for this. You have to add the following lines to the httpCompress section required by blowery in the web.config

<excludedPaths> 
      <add path="ebresource.axd"/>
      <add path="webresource.axd"/> 
</excludedPaths>

Having fixed the web pages, I still wanted to do something about those huge Atlas files. Luckily some smart Atlas developers at Microsoft have coded a compression routine for the resource files that are served through webresource.axd. You can enable it by adding the following line in the httpModules section to your web.config.

<httpModules>
      <add name="WebResourceCompression"
           type="Microsoft.Web.Services.WebResourceCompressionModule" />
</httpModules>

An important point to note is that this needs to be above the blowery http module. That is blowery also is an httpModule that needs to be added to the httpModules section in the web.config. However by keeping the add tag for blowery above the atlas module, my Atlas JavaScripts were not getting compressed. Moving the tag fixed the problem.

Have fun!


Enable AJAX with Atlas

Start off by downloading and installing the latest CTP from the asp.net site. Watch the "Get Started with “Atlas”?" video on this page to install and setup Visual Studio to be Atlas ready. You can then watch the other videos that show how to use some neat tricks to avoid server postbacks.

For the view comments feature on my blog, I created the following:

  • A custom control (by extending System.Web.UI.WebControls.WebControl) that accepts a dataset as a property and loops through the dataset in the Render method to output the necessary html.
  • A webservice that talks to my business logic, gets the necessary data, passes it to the custom control and outputs whatever the control renders.

Let's look at a simple example:

HelloControl.cs

public class HelloControl : WebControl
{
      private string _text; 
      public string Text
      {
            get { return _text; }
            set { _text = value; }
      }
      protected override void Render(HtmlTextWriter writer)
      {
         writer.Write("<span style='font-weight:bold;color:#dd0000'>Hello "
                       + _text + "</span>");
      }
}

All this control does is given an input text, it outputs the text in bold and red.

HelloService.cs

class HelloService : WebService 
{ 
      [WebMethod] 
      public string SayHello(string name) 
      { 
            HelloControl c = new HelloControl(); 
            StringWriter writer = new StringWriter(); 
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); 
            c.RenderControl(htmlWriter); 
            return writer.ToString(); 
      } 
}

That's it, you now have a webservice that spits out html which can then be used to fill certain sections of your web page. You can watch the "“Atlas” Enable an Existing Web Service?" video to see how to use webservices on the client side using Atlas.

Have fun!


Atlas

I have been playing around with atlas for the past couple of days. For those who don't know about atlas please visit here. It is a new AJAX framework that sits on top of ASP.NET and let's you enable AJAX on any ASP.NET control.

Today I added two features to the site using Atlas.

  • Ability to view comments without going to the feedback page
  • Ability to navigate the calendar without page refresh

UpdatePanel in Atlas is an awesome control. In order to enable AJAX on the Calendar control all I had to do was to add the UpdatePanel control on the ASP.NET page and move my existing Calendar control inside it. That's it, I now have a calendar control that can be navigated without a page refresh.

I will explain the code behind the view comments feature in another post.