New software/.NET articles are going up at http://www.exceedio.com/team/jreese/. This will be my last entry here.
Today I was working on localizing a web application into the the languages that BabelFish supports. After doing one .resx file by hand I decided that there had to be a better way.
That's when I started looking at the BabelFish web service. After some tweaking to the downloaded WSDL (missing attributes and incorrect namespace for what wsdl.exe is expecting) we have a console application that takes an English resource file and generates resource files for the other languages that BabelFish supports.
This was so easy that somebody has got to have done it before me. I know that the translations are not perfect by any stretch of the imagination, but they're a good start.
Source and binaries at http://www.codebehind.net/localizer.zip
Actual email from a friend at AOL regarding another friend at TI...
You think h4x0rs hack during business hours? My man is on top of those criminal techno-masterminds like white on rice. Subesh is up at 4:30 in the morning pouring thru IDS logs with mad regexes finding h4x0r attempts.
You think he has time for sleep? No...I don't think so. Son, we live in a world that has firewalls, and those firewalls have to be guarded by men with scripts. Whose gonna do it? You? You, Lt. Reese? Subesh has more responsibility here than you can possibly fathom. You weep for open systems and yet you curse the security auditors. You have that luxury of not knowing what I know. That Subesh's lack of sleep and obsession with gay porn, while tragic, probably saves lives. And that his existence, while grotesque & incromprhensible to you, saves lives. I know deep down in places you dont talk about at parties, you t want Subesh harderning your firewall, you need him on that DMZ host! We use words like buffer overflow, code review, setuid. We use these words as the backbone of a life spent!
For more comedy gold see this comprehensive collection of movie titles by the same author. The "you had to be there" factor is pretty high on some of these but they might still give you a chuckle.
I'm currently working on several different web projects on my WinXP Pro development machine. Not all of these projects reside in virtual directories, so I have the need to change the home directory of the default web site a lot. Here's a batch file that will make all of the necessary changes in one step. It assumes that you have the IIS5 admin script 'adsutil.vbs' installed on disk somewhere (but not necessarily available via IIS for security reasons).
if "%1" == "" goto usage
REM * Add one line for each web project *
if /i %1 == project1 set webroot="C:\Development\Project1\Website\wwwroot"
if /i %1 == project2 set webroot="C:\Development\Project2\Website\wwwroot"
if exist %webroot% (goto begin) else (goto notag)
echo Changing IIS metabase settings...
C:\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/Root/Path %webroot% > nul
echo Deleting Visual Studio.NET web cache...
if exist "%USERPROFILE%\VSWebCache" rd /s /q "%USERPROFILE%\VSWebCache"
echo Restarting IIS...
echo This command modifies the home directory settings of your primary
echo web site and removes the contents of your Visual Studio.NET web
echo cache. It is used to automate the process a developer navigates
echo when developing multiple web sites on a single machine.
echo Usage: changeiis.cmd [website tag]
echo Example: changeiis.cmd project1
echo "%1" does not map to a valid directory.
Nearly every software application I've written in the last five years, web or otherwise, has interacted with an underlying relational data-store, which in turn is nearly always SQL Server. This might explain my preoccupation with data access patterns.
After following a discussion regarding the merits of MVC started by Chris Anderson, I started to question my own use of design patterns. I've played around with object mappers such as Microsoft's ObjectSpaces. I've used DataSets to hold everything. I've passed XML to and fro. The data access method of choice I eventually settled on was custom data access classes with custom entity classes and the abstract factory pattern.
It goes something like this:
Start by defining one or more entity classes (Customer for example). Then define a set of data access interfaces for each entity (ICustomerDao). These interfaces define the basic CRUD methods and accept/return your custom entities. After the interfaces are defined, you define a factory interface that serves as the abstract data access factory (IDaoFactory). With the entities and interfaces in place, you can now write your data-store specific concrete implementations of the data access interfaces (SqlServer.CustomerDao) and the factory (SqlServer.DaoFactory). The idea is that some day when your data-store changes you can just write a concrete implementation for that data store (Oracle.CustomerDao, Oracle.DaoFactory) and just use the appropriate factory. You can even use the Activator class to dynamically determine which factory to use based on a configuration file setting.
The problem with this approach is that it’s a lot of work. I'm guessing 2 hours/entity. You’ve written all of your entities, interfaces, and concrete implementations before you’re even dealing with any business logic. I know I'm lazy, but that’s a lot of code to write for your average in-house expense tracking application.
Today I decided to explore the other end of the spectrum… dragging a table on to the Visual Studio .NET Schema designer, creating a typed DataSet from the schema, and using the DataAdapter wizard to automagically create a bunch of CRUD that supports a version of optimistic concurrency. Time elapsed: 3 minutes.
Do I get the feeling of satisfaction of knowing that I’m writing a highly extensible, maintainable application? I'm not sure yet. Do I get the best performance for my buck? Not really. What I do get, though, is an extra eight hours to read up on Remoting, WS-*, and other topics of interest from my favorite bloggers.
I've been using Syndirella for a few weeks now to keep up with a number of software related blogs. Having recently discovered blogs, I have found them invaluable in helping to keep me in touch with my development community of choice.
Working for Microsoft - even if it was the often maligned mountain view campus - was always a creepy dream of mine, and after leaving to do consulting full time I really miss the sense of community and the direct access to some really great minds.
I learned a lot from my colleagues and hopefully I'll be able to give something back.