May 2006 Entries

MSBuild and Web Application Projects

One of the benefits of moving to .NET 2.0 is having a clean build computer. A build computer is a machine where software can compile in an isolated environment, and away from the quirkiness of a machine in day-to-day use. The goal is to produce repeatable builds for test and production with no manual steps and a minimum amount of overhead. Since the .NET framework 2.0 installation includes MSBuild.exe (which can parse project and solution files, compile source code, and produce binaries), there is no need to install Visual Studio on a build machine. Web Application Projects throw in a...

Encrypting Identities In Web.config

Rob Howard wrote a piece for MSDN Magazine on “Keeping Secrets in ASP.NET 2.0”. The article is a good introduction on how to encrypt configuration data in web.config. Something I’ve had to do which wasn’t immediately obvious to me was encrypt the identity section of web.config for a specific location. For example, let’s say I don’t want the username and password in the following web.config file to appear in plain text. <?xml version="1.0"?><configuration>  <identity impersonate="false"/>  <appSettings/>  <connectionStrings/>  <system.web>     <compilation debug="true"/>     <authentication mode="Windows"/>  </system.web>  <location path="admin">   <system.web>      <identity impersonate="true"             userName="***"             password="***"     />   </system.web>  </location></configuration> From the command line, a first crack at encryption might look like the following … >aspnet_Regiis -pef system.web/identity e:\[path to...

Can you tell a green field from a cold steel rail?

Google Trends is in fashion these days. The tool will slice and dice relative search volumes by city and geographic region. I can’t see anyone mining useful data to make strategic business decisions based on relative volumes, but I do see an endless source of fodder for intellectual debates. These numbers are wide open for interpretation. Here are my explanations: People are most interested in you when you have something to give them. Fame is fleeting. Don’t eat turkey in Portland or Seattle. The world is divided on the spelling of aluminum. Finally, more people search for statistics than they...

What Software Taught Me about Gasoline

Years ago, I wrote embedded firmware for 8-bit devices. One set of portable devices could calculate the octane rating of a gasoline sample by measuring the sample’s absorption of near-infrared light*, and are still in production today. Agencies could use the device to make sure gasoline stations were selling gas with the octane ratings they advertised. In the U.S., gas stations typically sell at least two grades of petrol: regular and supreme. Supreme commands a 10 to 15 percent price premium. Regular gas is around 87 PON**, and premium is about 91 PON. During that time, I learned that buying gas with...

Reactive Web Development versus Continuations

There is an appealing simplicity to the following code. While GetNextCustomer()     TakeCustomerOrder()     SendOrderToKitchen()     WaitForPizza()     AcceptPayment()End While The software’s goals are exposed. The essence remains free from the details of collecting data and rendering results. When a few bad customers raise food costs by ordering pizzas and then disappearing, even a pointy-haired boss can cut and paste the solution, which is to make customers pay before sending an order to the kitchen. Unfortunately, only textual command line applications can come close to resembling this pseudo-code. We build graphical applications, and shred the logic across event handlers. We hide the essence of the...

Process, Process, Process

Peter Bromberg posts some good rants on his unblog. His recent entry “Is Your Development Process Broken?” was timely. Several months ago, a friend of a friend called me about a web app with a performance problem. I was going to turn the gig down because the app was written in C++ as an ISAPI extension. I haven’t touched either C++ or ISAPI for years and have no desire to relive those days*. As it turns out, the performance problem was relatively easy to solve. SQL Profiler revealed a single page that could generate over 500,000 roundtrips to the database...

Session State Uses a Reader-Writer Lock

To prevent two pages from modifying in-process Session variables at the same time, the ASP.NET runtime uses a lock. When a request arrives for a page that reads and writes Session variables, the runtime acquires a writer lock. The writer lock will block other pages in the same Session who might write to the same session variables. It’s easy to see the runtime implications of the lock when using two pages in a frameset. Here is a page that executes quickly: <%@ Page Language="C#" %><script runat="server">  protected void Page_Load(object sender, EventArgs e)  {    Response.Write(DateTime.Now.ToLongTimeString());  }</script><form runat="server">  <asp:button runat="server" text="refresh" /></form> Here is a page that executes slowly…...

SQL Brainteasers

I love the little challenges Ayende Rahien puts on his blog. The last SQL challenge was to convert a table like this: FromDate ToDate 01/01/2000 01/31/2000 02/01/2000 02/28/2000 03/05/2000 03/31/2000 Into this: FromDate ToDate 01/01/2000 02/28/2000 03/05/2000 03/31/2000 Where adjacent date ranges collapse to a single record. The first step was to setup some experimental tables. CREATE TABLE #InDates(   FromDate datetime,   ToDate datetime)INSERT INTO #InDates VALUES('1/1/2000', '1/31/2000')INSERT INTO #InDates VALUES('2/1/2000', '2/28/2000')INSERT INTO #InDates VALUES('3/5/2000', '3/31/2000')CREATE TABLE #OutDates(   FromDate datetime,   ToDate datetime) I have to think about SQL in small chunks, so I first thought about how to get a resultset with a FromDate minus one day. That would give me a column to compare against another record's ToDate: SELECT DATEADD(dd, -1,...

Atomic Operations

Greek philosophers Leucippos and Democritus were among the first to postulate that all matter is composed of indivisible units they called atomos. Thus arose atomistic philosophy and the concept of an atom. (Note that the Hindu Vaisesika Sutra appears to pre-date the Greek thinking by 100 years or more). Curious humans continued to tinker over the next 2300 years until they got inside the atom. Nuclear technology is responsible for devices as useful as the x-ray machine, and devices as destructive as the television and atom bomb. Somewhere along the line, computer science adopted the term “atomic operation” to describe...

All Code Is Good

… even the code that doesn’t work. I use SourceGear Vault for personal work and experiments. SourceGear is free for a single user (see the last question in the Vault FAQ). When an experiment doesn’t work out I have a tendency to delete and purge the project from source control. I don’t want my repository cluttered with broken junk. Invariably, 3 months later I’ll run into a scenario I’ve tried before, but I don’t have the code because my first attempt didn’t work. I’m always wishing I had the old code to prove that an approach doesn’t work. Even worse is when...

At The Zoo

The Hub

In a nutshell: “F# is a programming language that provides the much sought-after combination of type safety, performance and scripting, with all the advantages of running on a high-quality, well-supported modern runtime system.” The well-supported modern runtime would be the CLR. Congrats to optionsScalper and gang for a successful launch of The Hub - a community site and THE place for F#.

Connascence of Algorithm

I’m not sure where the term “connascence of algorithm” originated from. The first place I saw the phrase was in the 1996 edition of “What Every Programmer Should Know About Object-Oriented Design”. The book contains a great deal of practical advice, although its terminology and notations are well out of fashion 10 years later. Two components share a connascence of algorithm when they both rely on a specific algorithm to work properly. If I change the algorithm in one component, the other component will need to adjust. In today’s terms, we’d say the components are tightly coupled in a bad...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14