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, 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. Posted in .net Comments (0) 30 May 2008The Perils of GetHashCodeRecently 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:
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. Posted in .net Comments (1) 9 May 2008TDD Anti-PatternsJames 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: tdd, test driven development, unit testing Posted in development, java, .net Comments (0) 8 Feb 2008Configuration Section DesignerJelle 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. Posted in .net, visual studio Comments (0) 23 Jan 2008Debug 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 Posted in .net Comments (0) 17 Jan 2008.Net does Dependency InjectionThe 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: lightweight container, dependency injection, enterprise library, inversion of control, spring Posted in .net Comments (0) 10 Jan 2008Resolution list for 2008A 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:
There’s nothing like turning your New Year resolutions public, or at least part of them… Posted in photography, java, .net, agile, rails, photogear, j2ee, linux Comments (0) 3 Jan 2008TechDays 2008The main .Net driven event in Portugal is up and running. Posted in .net, asp.net, visual studio Comments (0) 14 Dec 2007Volta
Any similarities between Bjork’s latest album and Microsoft’s latest toolkit for web development are just a pure coincidence. Posted in .net, internet, asp.net, ajax, visual studio Comments (0) 11 Dec 2007T4 EditorThose of you that have been working with DSL tools or software factories lately have missed this piece of software from Clarius: It works either with Visual Studio 2005 or 2008. Posted in .net, guidance automation, visual studio Comments (0) 31 Oct 2007 |
About myself