Monday, August 27, 2007

Graham, On Point


I was just missing the old Paul Graham, the one who would write wisdom for the type of programmer that I imagined myself to be. The most recent essay, Holding A Program In One's Head, is that treat I've been waiting for.


.NET 301 Redirect


Scott Hanselman was noting that many people who'd updated the locations of their tools on his 2007 Ultimate Developers Tools List had emailed or contacted him asking him to update his reference.

He lamented the fact that they didn't simply use HTTP 301 redirects (Moved Permanently) which tools can easily use to update referenced links.

I must confess, I was one of those people.  I just lazily made a default.asp that had one line:


But 301 redirect are pretty simple whether you use .NET or lazily throw an ASP script somewhere.

'classic ASP
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://foo/bar.asp"


Response.Status = "301 Moved Permanently";

Source: seoconsultants.


Friday, August 24, 2007



I embarrassed myself today (yelling at the work desk, telling everyone I'd take them to McDonalds) but with good cause: a tool I wrote some time back made it to Scott Hanselman's 2007 Ultimate Developer/Power User Tools List. The goal of the tool was simple: to do browser based evaluation of regular expressions using the .NET engine.  Prior to writing it I would frequent but because the engines supported there were different, I'd usually have to do some conversion to get things to the .NET world.

There are quite a few .NET Regular Expression tools: Expresso, which is my first and favorite since I've used it longest, but also tools like Roy Osherove's The Regulator. The problem with these tools, however, was that as fat clients I wasn't always easily able to use them: I work on different machines (home, work, client sites) and also assist people quite a bit away from my desk.

There are also quite a few Regular Expression tools for the web, Rexv, which I mentioned before but also RegexPal. But these tools support either javascript or alternate implementations so patterns like (?<foo>\w+) usually return some kind of error. 

The way Nregex works is pretty straight forward: I'm using YUI for the Ajax library and working with the .NET implementation of the regular expression on the server.  A simultaneous goal of mine is to get into more of YUI because I'm always building little knick-knacks in javascript and I think it's the library to beat right now.

Of course it's a fledgling: I worked on it a few nights when I could and fixed bugs here are there when I had a moment.  Please use it and give me feedback since that will be my biggest help in making it better.

One more thing: I'm trying to collect useful regular expressions. I'd like to build a good library of expressions to help users of the tool. Use the feedback form and let me know if you've got one you've found handy. Don't worry if it's not .NET specific, I'll do the translation.


Sunday, August 12, 2007

What Comes First?


Although it's an older essay (November, 2004), The IDE Divide made for some good Sunday reading. Not only is the author, Oliver Steele, engaging but his visualizations are exceptional. I'd like to think of myself as a "language maven" - that is a person who puts the emphasis on language capabilities before tools - but I know that growing up in the Microsoft world as I did, I understand how big of a difference good tools can be.

One item I don't recall seeing in the essay was how tool mavens are responsible for their own obsolesence. It makes perfect sense to focus on language first and be flexible with tools - and to have a good text editor you can rely upon. I started using Textpad first with Java and nowadays I usually don't pass a day when I don't open something with it - either for quick inspection of a file or to write something in perl or python.

I know there are other good text editors out there but it seems like having good regex support and the ability to attach shell commands to keyboard shortcuts is most important. Syntax highlighting is a nicety too although as time passes it's not really as important to me.


Tuesday, August 07, 2007



Some time ago Jason Kottke posted an entry for which quite a few people bashed him about unnecessary database normalization. I've thought a lot about it since it represents some of my own internal sentiments and instincts. The two things I observe on a regular basis that I find annoying are bad naming conventions within databases and unnecessary complexity because of overzealous normalization.

It's hard to have an argument discussion on the topic with people lacking experience because the penalties for bad normalization are usually paid in the long term whereas the "effeciency" of storage with normalized data seems to be an ideal to strive for when one's perspective is short.

I was therefore heartened to see some caution from Patt Heland (courtesy of Dare Obasanjo who elaborates) on the topic. It may be a good idea to have a meeting at work and discuss some of the details given... maybe not to come to some "conclusion" or "database standard" that can apply to every situation, but more to generate good discussion and ideas.


Wednesday, August 01, 2007

Upsert Properly


For the longest time, my approach to update/insert logic has been the following:


So courtesy of .NET Kicks this gem was very informative which is the same logic but with a cleaner approach. Instead of selecting records first, you attempt to do an update and check afterwards if the @@rowcount is greater than zero - if not the record doesn't exist so you can move logically to an insert.


IF @@rowcount = 0 BEGIN

Nifty, very nifty.