Jeff W. Barnes

Ramblings on C#, WCF, and random .NET

January 2007 - Posts

Where are the book reviews?

Last July, I posted a book review on Framework Design Guidelines.  At that time, I had started to read a technical book once a month and post a review of it on my blog...or at least attempt to do so.  I managed to stick to it for about three months, but the hectic nature of the holidays (among other things) wore me down and I stopped doing it.

I have decided to resume the monthly book reviews in February (as if I didn't have enough to do already).  I started reading some of Applying Domain-Driven Design and Patterns, which had been lying around for a couple of months collecting dust.  I also have pre-ordered Juval Lowy's Programming WCF Services, which is supposed to ship next week.  I'm very anxious to see the depth of information it provides. 

One of these books will likely be the next one that gets reviewed.

Grade Your System Architecture Knowledge

I am a frequent reader of the Inside Architecture Blog.  Yesterday, Nick Malik posted a good read that reveals his expectations of candidates interviewing for a position as a system architect.  He also covered some various scenarios used as the basis of certain interview questions.

Anyone interested in moving into a more of a system architect role should read his post.  Nick's position requirements and interview exercises provide an excellent overview of the necessary skills.  It's an easy way to give yourself some honest feedback.

This is of personal interest to me because I am working to transition toward more of a system architect role.  I know of quite a few people with similar ambitions, so I thought others might find it useful as well.

Enjoy!

GoF Design Patterns

I imagine just about everyone in programming has heard of the Gang of Four (GoF) design patterns.  The GoF were the four authors of the well-known book Design Patterns: Elements of Reusable Object-Oriented Software.  This book was the foundation for many of the popular design patterns that are currently in use and served as a significant source for object-oriented theory.  It was originally published in 1995, but there is still so much demand for the book that it continues to be printed and sold over ten years later (which is rather impressive for a technical book IMO).

Design patterns are a very important part of software development.  They provide a proven, recurring solution for many common problems that arise from project to project.  It can easily make the difference between a sound solution and a maintenance nightmare. Any good developer or architect should possess a sound understanding of the fundamental design patterns.  Unfortunately, I know a lot of people in the industry that consider design patterns to be purely for academia with little practical use in the real world.  (I am not one of them!)

At any rate, I finally come to the original purpose of this post.

There is a great site to get a better understanding of the GOF design patterns: www.dofactory.com.  They have a description for each pattern along with UML diagrams and example code.  You will find the majority of the information to be available for free.

I have known about this site for quite some time and referenced it on numerous occasions for brushing up on patterns that I don't use very often.  However, I was recently on their site and decided to purchase their premium product.  I was very pleased with the content, so I thought I would mention it on my blog.  The download contains a complete VS2005 solution containing all of the code for each pattern listed on their site, code for additional patterns not listed on the site, Visio UML diagrams, and code for a website that demonstrates real-world use of several different patterns.  The code is available in C# or VB.NET.  You can view the details of the offer here: http://www.dofactory.com/Framework/Framework.aspx

If you are interested in learning more about design patterns, it is definitely a resource worth consideration.

Birmingham .NET Framework 3.0 Launch Event

I meant to blog a reminder about the event last week, but I am a little late now.

Today was the local launch event for .NET Framework 3.0.  Unfortunately, I missed it.  It has been one of those weeks where there literally just aren't enough hours in each day.  I simply had to juggle too many obligations to make it downtown.  From what I hear, the event went really well and was nearly filled to maximum capacity.  It is encouraging to see the Birmingham technology community continue to grow and prosper through these type of events.  I hope that all of you who attended really got something out of it...other than just swag. 

.NET 3.0 is a giant leap forward for developer productivity as well as the capabilities of the platform.  Even though the presentation material is typically at a higher level, there is significant benefit to attending these type of events.  They are an excellent way to get an introductory look at the capabilities of the platform.  I encourage you to take a closer look by digging into some of the specific areas that interest you. 

I hate that I missed the opportunity to network with so many members of the developer community around such cool topics.  It is always fun to chat with folks about power and potential of WCF.  But, just because I missed the event doesn't mean we can't talk about WCF.  Feel free to drop me a line via the form on my blog, which you can access here.  I am always happy to talk tech...especially around WCF (or anything related to services for that matter.)

Cheers!

File Checksum Performance Comparison

Last week, I made a brief post about easily using some of the cryptographic hash algorithms available in the .NET Framework for the purpose of generating a file checksum.  After giving it some thought, I decided to do a follow-up post and compare the general performance of each algorithm.

Here is the setup of the test.  I wrote a method that accepts the path to a file as a parameter.  A stream is opened to read the file and compute the hash.  The result of the hash is converted to a string via a BitConverter.  The method was cloned for each algorithm being tested: MD5, SHA1, SHA256, SHA384, and SHA512.  Each algorithm was tested against a 50K, 100K, 500K, 1MB, and 5MB file.  The checksum was calculated for the given file 1000 times to obtain a reasonable measurement.  Furthermore, I ran each test three times to obtain an average result.  (Refer to my previous post for an example of the code.)

The test was compiled in Release Mode on .NET Framework 2.0.  It was executed a computer with a Pentium 4 3.06 Ghz CPU (with Hyper Threading) and 1GB of memory running Windows XP.

Please keep in mind that this was not a certified experiment.  It is simply something that I threw together for the sake of curiosity.  In other words, draw your own conclusions before accepting the results as a universal law.  It isn't meant to be incredibly precise.  The point is to emphasize that overall performance decreases as the strength of the hash increases.  The difference becomes even more obvious as the size of the file increases.

Here are the results.  The times are listed in seconds.  This indicates how many seconds it took for the given algorithm to compute a hash 1000 times for the given file size.

Algorithm 50 K   100 K   500 K   1 MB   5 MB
MD5 0.359   0.578   2.422   5.13   21.875
SHA1 0.781   1.469   7.115   15.427   70.078
SHA256 1.109   2.109   9.891   21.807   96.98
SHA384 2.688   5.36   26.224   57.656   256.641
SHA512 2.703   5.391   26.719   57.691   263.625

Here is a chart with the plotted data to give you a better visualization:

File Checksum using .NET

It seems there are a number of people out there who attempt to write their own checksum algorithms for validating the integrity of a file.  However, these type of algorithms need to be incredibly reliable.  Unfortunately, the "home-grown" version is often error prone.  Typically, the developer will do enough testing to assure himself/herself that the algorithm works.  Unfortunately, they usually find out it wasn't so reliable as once the code is in production.

Unless you have a compelling reason to create your own, why not use the what the .NET Framework already provides.  The System.Security.Cryptography namespace contains several different implementations of cryptographic hash algorithms.  These have already been thoroughly tested and are widely used.  You can take your pick from MD5, SHA1, or any of the SHA2 variants.

Here is a snippet of creating a checksum via SHA256:

using System.IO;
using System.Security.Cryptography;

private static string GetChecksum(string file)
{
    using (FileStream stream = File.OpenRead(file))
    {
        SHA256Managed sha = new SHA256Managed();
        byte[] checksum = sha.ComputeHash(stream);
        return BitConverter.ToString(checksum).Replace("-", String.Empty);
    }
}
Huntsville .NET University - WCF Slides

Last night, the first segment of .NET University was held for the Huntsville, AL area.  There was a very good turnout...especially if you consider the BCS National Championship game was being played during the event.  As usual, Todd presented WPF and I presented WCF.  We had a good time and certainly appreciated the hospitality and enthusiasm demonstrated by the user group. 

Once again, I used a slightly modified slide deck from the standard issue for .NET University.  So, I have posted them for download here

Mix 07 Registration Open

I noticed that the registration for Mix 07 has officially been opened.  If you aren't familiar with Mix, it is essentially a three day conference about cutting-edge web development and business opportunities.  For companies whose business depends on the web, it is definitely worth the trip. 

Todd and I attended Mix 06 last year.  If this year is anything like the last one, I highly recommend attending.  It was a lot of fun and highly beneficial from a learning perspective due to the exposure to the latest, greatest technologies and business opportunities.  We will hopefully be attending again this year.

Once again, it will be held at the Venetian Hotel in Las Vegas from April 30 to May 2.  The price is $1195, but you receive a $200 dollar discount as part of their early bird special by registering before March 15th.

Check out the website for additional details at http://www.mix07.com.

Posted: Jan 05 2007, 09:02 AM by jeff.barnes
Filed under:
New Years Resolution - The Technical Version

I have been rather slacking on blog posts over the last month or so.  Between the baby, work load, and the hectic nature of the holidays, it has been difficult to find the time to keep up with blogging.  So, I thought it would be appropriate to start out the new year by posting the technical version of my New Years Resolution since it is related. 

  1. Produce a minimum of two useful blog posts each week
  2. Devote a few hours each week to answer questions in the technical forums
  3. Continue to expand my knowledge of WCF and write several advanced demos

There you have it.  Stay tuned during the course of the year to see whether I live up to my own expectations.

Good luck to everyone with their own resolutions.

Posted: Jan 03 2007, 10:14 AM by jeff.barnes | with 1 comment(s)
Filed under:


Disclaimer:The opinions and views expressed within this blog are solely my own and do not represent those of my employer or anyone else.