From Kent Beck’s book Test-Driven Development By Example I’ve learned a few quite simple rules.

The two essential rules:

  1. Write new code only if there is a failing automated test
  2. Eliminate Duplication

The more systematic way of doing TDD:

  1. Add a test
  2. Run all tests and fail
  3. Make a little change
  4. Run tests and pass
  5. Refactor to remove duplication

This method can be broken down even further to:

  1. Red – write a failing test
  2. Green – make it pass
  3. Refactor – remove duplication

This is more widely known as the TDD Mantra.

The ability to work in small steps thus strengthens our confidence in the software we build.

In programming, if you fear the unknown, write some tests!

If Internet Explorer (IE) detects an error message from the web server less than 512 byte, it shows it’s own “friendly” error message.  As a web developer you should turn off the default friendly error page setting on IE.  It will help tremendously when debugging simple HTTP issues.  For more complex issues I suggest the excellent free tool Fiddler).

To change the setting:

  • Tools –> Internet Options –> Advanced Tab
  • Browsing –> Show Friendly Http Error Messagesimage

Before with it on:image

Here it is with the option turned off:image

This is a simple HTTP 404 example, but it clearly states the problem.

Old news from 9/15, but I want to weigh in.

Yes, it’s true, Microsoft has a free CDN for their JS framework.  This is great news for people who use Microsoft AjaxLibrary (… version 4.0 Preview 5!). 

Here is the usage:

<script src="http://ajax.microsoft.com/ajax/beta
/0909/MicrosoftAjax.js" type="text/javascript"></script>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Notice it goes to ajax.microsoft.com. This could potentially already be cached by the user’s browser.  The beauty of a CDN is you don’t have to worry about the location of the server serving the JS file.  It’s a network of servers that are geographically dispersed at key Internet network points.  This minimizes the amount of network hops to your user and relieves the bandwidth on your server.  Plus it frees up another request for the user to download more content off your server (older browser have max 2 connections to a FQDN).  This speeds up the “perceived” rendering of the web page.

But who uses MS Ajax?

Google Ajax Libraries API, Google’s CDN, contains all major JS frameworks except for MS Ajax.  This begs the question the of MS Ajax penetration in the market.

image

Earlier this year a survey was conducted with over 1200 self professed web professionals and posted on Ajaxian regarding the state of the web in 2008.  One of the questions surveyed was which JS frameworks they use, and MS Ajax was nowhere in site and jQuery dominating.

image

I admit when MS Ajax first came out, I played around with it and used it for some of my sites.  I even created my own extender that is used in SharePoint WebParts.  But since I moved to jQuery almost 2 years ago, I have not looked back.   So in the end, it’s too little too late for me.

Resources

This is old, but more of a note for me to go checkout the videos from this year’s Norwegian Developer Conference.

You can grab the videos from here.

Overview

This will be the first part in a series of tips on some ReSharper goodness.  For the people that don’t know what ReSharper is, it’s a productivity tool for Visual Studio.  It installs as plug-in and enhances the user experience tremendously.  I will never go without ReSharper again.

Here is list of some of the features:

  • on the fly code analysis
  • code assistance (C# 3.0 ready!)
    • quick fixes
    • suggestions
    • auto complete
  • error highlighting
  • advanced code refactoring
  • navigation
  • unit testing
  • code templates

If you are a keyboard junkie, it’s got hotkeys for everything and you won’t ever have to use that crutch mouse hardly ever again.  I suggest you download the 30 day trial and see your productivity increase yourself!

Tip #1: Current Line Highlighting

Example:

image

That is clear call out to what line you are currently working on.  I love it.  You want it.  So how?

Step 1: Turn on highlighting

  • Go to the ReSharper Options (ALT+R, O)
  • Select Editor
  • Check “Highlight current line”
  • Click OK

image

You can also modify the color of the current line option.  It’s pale yellow by default, which isn’t enough for me apparently.

Step 2: Change highlight color

  • Go to Tools –> Options (ALT+T, O)
  • Expand Environment
  • Select Fonts and Colors
  • In Display Items, go to ReSharper Current Line
  • Change Item background color to your choice

image

*note all steps and pictures are with Visual Studio 2008

Dynamic Data is a great way to expose your site to the web for easy administration.  It creates basic CRUD screens out of the box based on your database and foreign key constraints.

Create a new Dynamic Data Web Application

  • File New –> Project

image

Create a new folder named Model in the solution.

Add a new LINQ to SQL Class and name it something like “SomethingModel”.  Drag the necessary tables that you want to use with Dynamic Data.

There are two things you must do to get scaffolding hooked up.

Open up the Global.asax.cs and modify the following on line 29 with the new LINQ to SQL Class you created (SomethingModelDataContext).

image

Enable scaffolding for all tables

image

Then hit F5 and watch the magic happen!

If you wish to build Castle from command line quickly:

  1. Grab the latest from the Castle SVN Repository
    1. http://svn.castleproject.org:8080/svn/castle/trunk/
  2. Open a command shell and go to the root directory of where the castle project is located
  3. Run the following command to build without tests:

build

    1. This internally calls quick release clean build

First post, and it’s a meta post.

I previously had a blog at ASP.NET blogs, but decided to ditch it for WordPress.  Why?  Well obviously WordPress is the premier blogging service.  Plus the CMS is far superior than what is offered over at Microsoft.

Now that I am officially on WordPress, I wanted to use LiveWriter (LW) as my blog editor.  It has a nice community and a plethora of extensions that I could not live without.  So without further ado, here are the steps to get it setup with WordPress:

  1. Get Live Writer
  2. Start LW
  3. Add Blog account
  4. Select other blog service
  5. Enter the blog url:  http.<username>.wordpress.com/xmlrpc.php
  6. Enter Username/Password

The key is the XML RPC page that allows you to remotely interact with your blog with any external application, LiveWriter in this instance.