The Perils of GetHashCode, continued…

Some time ago I wrote about GetHashCode method and now Paulo Morgado has also faced some “hash related” issues to deal with (also in Portuguese). Again, the reminder should be not rely heavily on GetHashCode.


The Perils of GetHashCode

Recently I ran into some unexpected, and rather strange, issues on an application server using the Enterprise Library 2.0 Cache Application Block. Apparently there were occurring some strange collisions while retrieving the data from CacheData (the table where the cached data is stored) where the same cache key was having multiple entries, something the Dictionary container where the data is stored isn’t too happy about. The guys at Patterns and Practices, for performance issues, don’t use the cache key as a primary key for that table, but a much more efficient and more easily indexable” integer, which, in this case, is being calculated using the GetHashCode of the cache key. Usually the GetHashCodeimplementation isn’t a fully blown hash algorithm (unlike the more robust MD5 or SHA) so I allways doubted of the uniqueness, particularly in this case where the application server was moved from a 32 bit to a 64 bit architecture, nothing a quick trip do the good old MSDN wouldn’t confirm:

Remarks

The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language runtime to another. A reason why this might happen is to improve the performance of GetHashCode.

This basically means you shouldn’t trust GetHashCode, because the result for a given string can, and surely will, be different depending where you are calculating it, namely between 32 and 64 bit architectures. The main lesson to be learnt here is GetHashCode, either for String or any other type, should only be used for disambiguation of entities in runtime.


TDD Anti-Patterns

James Carr has compiled a pretty little list of Test Driven Development Anti-Patterns and posted it some time ago in his blog. I have to admit I’ve done some of them once or twice.

TDD Anti-Patterns [via ISerializable]

Technorati Tags: , ,


Configuration Section Designer

Jelle Druyts has released a neat little tool for Visual Studio that allows to easily design and visualize the configuration for a .Net solution, without messing around with ConfigurationSection and ConfigurationElement source files, which is quite handy when things become a bit more complicated. It’s still is in an early stage, but it looks rather promising.

Configuration Section Designer


Debug THE .Net!

Hey, now I can debug the .Net framework or, in other words, now I can’t blame the framework every time I have a problem.

.NET Framework Library Source Code now available - ScottGu’s Blog


.Net does Dependency Injection

The next version of Microsoft’s Enterprise Library will include several improvements on the existing blocks and, this is the cherry on the top, a lightweight Dependency Injection container (or Inversion of Control, if you prefer it this way), probably much like the core of Spring.NET.

Enterprise Library v4 Product Backlog

Technorati Tags: , , , ,


Resolution list for 2008

A new year is now beginning and that usually means New Years Resolutions, so here are mine, just the geek oriented and in no particular order:

  • Finish TemujinPhoto, finally I’m working on it and in a few weeks I hope to have a working beta.
  • Probably this is the year I’ll take a certification, most likely a Microsoft Certified Professional. Probably…
  • Take photos.
  • Must dive into .Net 3.5 and LINQ.
  • Been thinking about creating a desktop client for Remember The Milk in WPF, I’m needing one and the guys at RTM have a neat API (WPF is for learning something new).
  • Must buy a tripod, need to do night shots.
  • Get a taste of EJB 3.0 and the Spring 2.5, just a small taste to check what I’ve been missing on the Java world.
  • Put my reading up to date, I still haven’t read this one (no need to buy me a copy, I already own one and it has been gathering dust for some time).
  • Take more photos: night photos, motion photos, street photos, concept photos and all kinds of photos I haven’t been doing lately.
  • There has been some ideas to make a few short movies, I sure hope we can turn them real. Another reason to buy a tripod…
  • Probably dump Windows on my laptop completely, I’m getting happier with Ubuntu everyday.

There’s nothing like turning your New Year resolutions public, or at least part of them…


TechDays 2008

The main .Net driven event in Portugal is up and running.

TechDays 2008


Volta

Any similarities between Bjork’s latest album and Microsoft’s latest toolkit for web development are just a pure coincidence.

Microsoft Volta


T4 Editor

Those of you that have been working with DSL tools or software factories lately have missed this piece of software from Clarius:

T4 Editor

It works either with Visual Studio 2005 or 2008.


Design by: Derek Punsalan
RSS