Sunday, March 30, 2008

Patterns Of Enterprise Application Architecture

I just finished reading Martin Fowler's book, P of EAA. Fowler does a great job of presenting various ways to approach solving each given enterprise architecture problem in an object-oriented way and explains the circumstances that will suit each solution and where each solution starts to fall down. This is a welcome change from books and blogs that preach The One True Way.

As Ayende has blogged recently, the patterns described in the book made a lot of sense of code like that in the NHibernate framework and at the same time convinced him that there is no real reason to re-implement those patterns. While I agree that implementing all the required structures yourself is both a large task and a good reason to "buy" an existing system, learning to code something like this yourself can really help to improve your understanding.

Fowler also opened my eyes as to how various classes in the .NET Framework relate to these patterns, and therefore, what methods for interacting with such classes work well. One example, is how ADO.NET's DataSet compares to the Unit Of Work. Rather than having a DataSet fill from a database, then exist for the life of an application and commit back to the database at the end, instead the life of a DataSet should correspond closely to that of a particular business transaction.

The book also contains a good mix of both Java and C# examples, and highlights how, with different built-in tools in these two development environments, each of these languages implements a pattern with its own strengths. My only concern was that much of the discussion leaned toward web application scenarios. My preferred domain, smart client applications, have a different set of issues to solve but admittedly the book is about architecture patterns, not about smart client presentation patterns, so I can't complain.

I can recommend this book as a good read for anyone writing large business applications.

 Monday, February 04, 2008

Database Evolution

K Scott Allen just recently posted the final article in a series of five about managing the development and deployment of a relational database alongside your code in a team environment.

He highlights some common failing points and good solutions to tricky obstacles, most of which I've faced throughout my career and learned about the hard way. I haven't quite achieved the same level of streamlined schema management that Scott has but it's good to know I'm on the right track.

Visual Studio for Database Professionals projects have started to be included in our product source control and we are pushing this great but still relatively new tool to automate as much of our schema management as possible. No matter how good the tools are though, I'm not the only one who feels at least a few developers on any team "need to step up and get comfortable with SQL".

In fact, getting comfortable with effective use of PowerShell, in addition to SQL, has helped to get reams of lookup data (ie post codes, etc) into repeatable T-SQL scripts and also to manage deployment of schema changes to multiple sites.

I've also just ordered Refactoring Databases: Evolutionary Database Design by Scott Ambler and Pramod Sadalage. The book focuses on applying the same incremental refactoring techniques used in code to evolve a database schema over time with minimal upset to existing systems. I expect to find some real insight into database development in this book.

Ambler has recently recorded some good interviews on both .NET Rocks and OnSoftware and Pramod has an e-book on Recipes For Continuous Database Integration worth investigating.

 Tuesday, January 15, 2008

Adelaide Geek Dinner February 2008

In my last post about the Adelaide Geek Dinner, I intended to schedule the coming dinner for January. Unfortunately, if I scheduled it for the last weekend in January, that would coincide with the Australia Day long weekend and I imagine several people already have plans.

Therefore, the next dinner will instead be Saturday 2nd February, but once again at Cafe Buongiorno, Rundle Street, starting at 6:30pm. I have sent invitations via email to all the people who attended last time and also to those who couldn't make it.

If you didn't receive an invitation and would like to attend, contact me and I'll arrange it. Please RSVP by Thursday 24th January so I can ensure enough seats will be reserved at the restaurant.

I look forward to discussing all the interesting things that have been happening since the November dinner.

 Friday, December 21, 2007

Lambda for Regex

A few weeks ago I was trying to put together a quick regular expression for converting an entire English sentence into Pascal (or Headed Camel) Case. What would have been rather trivial in Perl was a little ugly in C#.

Tonight, in a typical midnight haze, I realised I could use a lambda expression to tidy it up a bit. Here is the result, short and simple, presented in unit test form:

[TestMethod]
public void ShouldRemoveSpacesAndCapitaliseWords()
{
   const string original = "Should remove spaces and capitalise words";
   const string expected = "ShouldRemoveSpacesAndCapitaliseWords"

   Regex rx = new Regex(@"(\s*)\b(\w)");
   string result = rx.Replace(original, m => m.Groups[2].Value.ToUpper()); 

   Assert.AreEqual(expected, result);
}

 Wednesday, December 19, 2007

Food for Thawte

I was trying to renew my Thawte Personal Email Certificates this week because they expire very soon. Unfortunately I was having zero luck requesting a new certificate via Thawte's certificate management website.

Whenever I reached the stage to choose a Cryptographic Service Provider, the VBScript that is supposed to fill the drop down list would fail with a generic "424 Object required" error and the process would go no further. I tried several PCs but all my machines at home and work are Vista with IE7 and Thawte's list of supported software does not list Vista or IE7.

I downloaded the Internet Explorer 6 Application Compatibility VPC image from Microsoft and was able to complete the certificate renewal then export the private key to a file and move it out of the virtual machine and install it on my workstation.

I tried IE7 on Vista 32-bit, 64-bit, non-admin, Administrator, Protected Mode On and Off, and tried adding the Thawte website to my trusted sites. None of this helped. I eventually decided to download the IE7 version of the App Compat VPC to see if Vista or IE7 is the problem.

I found that apart from a security warning, which helped me to track down the ultimate reason, the Thawte website works fine with IE7 on Windows XP. The reason is that the XEnroll.dll certificate enrolment control was replaced in Vista for a more secure CertEnroll.dll.

As usual, I'm disgusted that it has been eleven months since Vista went RTM and Thawte still haven't addressed this issue. It's even worse because the Betas and Release Candidates of Vista were around for even longer and these distributions exist so third party software and service providers can test their systems to be ready soon after launch.

 Sunday, December 16, 2007

Why Jon Galloway Is Horribly Wrong About Non-Admin

Jon Galloway and Jeff Atwood have been having a debate. Mostly the debate has been about anti-virus software, which is a topic that I have no strong feelings on one way or the other.

However, talking about anti-virus involves talking about security and risks and inevitably the topic of running as an administrator versus a limited user account gets mentioned.

Jon, though, more than just mentions running as a non-administrative user, he labels it as "just about impossible", and the benefits of living in a non-administrator environment is something I do have a strong opinion about.

I am a .NET developer. I develop console applications, windows services, websites, and smart clients. I do it all, not as an Administrator and not as a Power User, but I do it all as a standard user. I've been doing it this way since March 2006 and have never gone back.

I don't cheat either. Microsoft suggests running Visual Studio 2005 with increased privileges to avoid various issues. Bah! It works fine as non-admin. The only programs I run with increased privileges are installation programs... and they don't come along very often.

I'm not just using Visual Studio either. I sync my iPod with iTunes and keep my GPS up to date with TomTom Home. I use all the Office apps and I mount CD and DVD images with Daemon Tools. I write scripts in PowerShell and I test beta software in Virtual PC. I have a local install of SQL Server too.

It isn't just me either. Within six months, the other two developers I work with had joined my non-admin club after I had demonstrated not only how painless it can be but how it helps to ensure the software we develop will work when deployed to our clients' restrictive domain environments. Most of all I demonstrated how to be part of the solution to break the cycle of software that requires administrator privileges.

Ok, so far all these people I've mentioned who are running as non-admin could be considered very capable computer users and aren't the same as most people. Fair enough but how about the other less computer-savvy people I know who have been educated on how to work as a non-admin. People with jobs like call centre operator, machinist, automotive-electrician, and cook.

These are people running Windows XP to send faxes, play games, and surf the Internet, and most of them still type with one finger. Switching to an administrator account for occasional tasks is just a Fast User Switch away or, on domain-connected PCs, using the simple MakeMeAdmin tool.

Vista users get it even easier when an elevation prompt appears asking for an admin password when they need to install software or change a system control panel setting. I just don't understand why people think it is so difficult. And to be clear, there is no hidden magic here, I'm not touching the default ACLs on my file system or registry either.

To come back to where the debate began, my point is that running as a non-admin is not difficult and does not restrict productivity, but it doesn't necessarily help the anti-virus or malware situation either. Some basic tests do show that it helps in some common infection situations, but I'm confident that I would be able to easily write non-admin compatible malware if needed.

So, Jon, feel free to argue about the effectiveness of anti-virus products or how much being a non-admin protects from malware, but don't tell me non-admin is as usable as unplugging your computer. And Jeff, if you're going to suggest non-admin as a good option, at least lead by example.

By the way, I run 64-bit Windows at work and home too, just to reduce the list of compatible software even further.

 Friday, December 14, 2007

TFS Deployer and TFS 2008

Mitch Denny from Readify made two great tools available for Team Foundation Server last year. TFS Integrator provides Continuous Integration for TFS by registering for check-in events then triggering Team Builds and Dependency Replication. TFS Deployer provides automated deployment for TFS projects by registering for build quality change events then executing associated PowerShell scripts. Both of these tools were developed for TFS 2005.

TFS 2008 has just RTMed and it already includes check-in triggered builds in the box so TFS Integrator is less useful (except maybe the Dependency Replication but this can be done via other methods). TFS Deployer, though, is still very useful in a TFS 2008 environment... assuming you can get it to work.

TFS Deployer was originally developed against the TFS 2005 client libraries and, of course, we've uninstalled VS and TFS 2005 from most of our machines already so Deployer just falls over because it can't find the libraries.

TFS Deployer is not open-source (yet) so I can't fix it myself. However, in a comment Mitch suggests using binding redirects in the TFS Deployer config file to enable TFS 2008 support. Unfortunately he doesn't give specifics.

I decided to drop the TFS Deployer assemblies into Reflector and find the list of TFS libraries it uses so I could write the redirects. I updated the .config file and changed the build quality on some existing builds and happily discovered that it works. If you want to use TFS Deployer with TFS 2008, here is the section to add to the TfsDeployer.exe.config file:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.TeamFoundation.VersionControl.Client" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.TeamFoundation.VersionControl.Common.Integration" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.TeamFoundation.Build.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.TeamFoundation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.TeamFoundation.Client" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

 Wednesday, December 12, 2007

Planning Adelaide Geek Dinner Round 2

My first attempt to organise a dinner for developers in Adelaide exceeded my expectations. Everyone seemed to have a good time and expressed an interest to do it again... we tentatively agreed on January.

This time, I'd like to re-invite some of the guests who were unable to attend in November, and try to schedule an available time for everyone. I'd also like to get feedback on the choice of venue.

Last time I chose Cafe Buongiorno because it is located centrally in the CBD, offers separate accounts to avoid table-banking, and has convenient parking and public transport. Most people like pizza and pasta too. I don't want to bore people with the same restaurant every time so I'd like to hear suggestions for alternatives, but if you all like the cafe it can stay.

Also, I chose a Saturday evening last time so people didn't have to rush from work to get to the dinner but if Sunday or a weekday would be better, or perhaps a lunch-time event interests you, pass on your comments.

Finally, if you know any other developers who may be interested in attending, put them in touch with me and I'll ensure they get invited.