Friday, June 30, 2006

Cryptic IBM Filenames

I’ve been a user of the Rational Purify product on Windows for a while and recently downloaded a Linux version to play with. The name of the download file just reminded me of how difficult it is to deal with IBM and their web site. The download file name was C905GML.tar.gz. Now how am I going to remember the purpose of that file name? Sure I can rename it to have a PurifyLinux_ prefix or something like that, but how hard would it have been to include a meaningful product prefix to the file in the first place? It just seems dealing with IBM as a small fry is overly complex. When the original Purify for Windows purchase was made I got a myriad of documents in both email pdf and snail mail post form (duplicates of each other). The pdf files all had cryptic alpha numeric names and there seemed to be multiple codes/ids that needed to be remembered for all sorts of thing e.g. license number, software site number, ibm customer number, agreement number, ibm id, passport advantage site number, proof of entitlement. This was all for a single Purify for Windows purchase. I’ve had a similar hassle with MSDN from Microsoft. They just seem to overcomplicate the customer experience. Other smaller companies can still track their customers/products without all the hassle involved. Strange how the memory of a product purchase hassle is triggered just by a cryptic download filename.

PurifyPlusLinuxDownload

Monday, June 26, 2006

Regex Fail All

I’m currently writing a small utility which takes a snapshot of the state of a Windows system and reports back to base as to the system state. This is being done to assist in resolving an application problem where the program doesn’t respond for a minute or so and then goes back to being responsive. The application logs provide no indication of any problems and its difficult to get end users to perform any in depth analysis. Its also a short enough period of unresponsiveness that it usually goes away before any remote assistance sessions could be set up. The application is being called Torq Snapshot and will have some level of configurability to that certain portions of the Windows system can be interrogated in depth as needed.

To facilitate this a number of filters are being defined using .NET Regex functionality so that specific processes are to be included in the snapshot. The configuration options are intended to be used by software developers so they don’t have to be easy to use. A need arose where it was convenient to be able to set the filter to a Regex pattern that failed all matches. Regex is one of those software areas that I use rarely enough that it always takes me a short while to get up to speed again when its needed on an adhoc basis. The end result was that a regex of the form [^\d\D] or [^\w\W] can be used to always fail i.e. “notting” the “or” of two mutually exclusive sets. I was hoping that a straight [] would do it but that failed with a run time exception.

Saturday, June 24, 2006

Triplet

Yesterday’s post was just a quick test of the csharpformat web page kindly provided by Jean-Claude Manoli on his web site. The code was an excerpt from a noddy little class that I happened to create that day. It was just a convenience class that allowed three objects to be combined and used as a lookup key into a Dictionary. The actual scenario was a cache for PerformanceCounter instances that needed to be looked up based on the combination of a category name, performance counter name and instance name. I actually did search for an existing .NET triple class in the framework and found the System.Web.UI.Triplet class. Unfortunately it was associated with a web assembly rather than a more general purpose assembly. In addition it didn’t override the Equals and GetHashCode methods so couldn’t be used as a key in a hashtable/dictionary.

This is an example of a class where I question whether the fields shouldn’t be made public since it is only a convenience class and direct access to the fields is convenient depending on the context it is used in.  Fortunately there were benefits in making the class immutable so I didn’t have to face the encapsulation quandary. The class ended up being placed into the Torq.Foundation.Tool namespace so it can be used by code in a variety of contexts. Consideration was given to making it a generic class but getting the programmer to type Triplet<string, string, string> triplet = new Triplet<string, string, string>(); was just so way overboard given its typical expected usage as a key.

public class Triplet
{
    private object first;
    private object second;
    private object third;
 
    public Triplet( object first, object second, object third )
    {
        this.first = first;
        this.second = second;
        this.third = third;
    }
 
    public object First
    {
        get { return first; }
    }
 
    public object Second
    {
        get { return second; }
    }
 
    public object Third
    {
        get { return third; }
    }
 
    public override bool Equals( object obj )
    {
        Triplet triplet = obj as Triplet;
        if ( triplet == null ) return false;
 
        return Equals( first, triplet.first ) && Equals( Second, triplet.Second ) &&
            Equals( Third, triplet.Third );
    }
 
    public override int GetHashCode()
    {
        return GetHashCode( first ) ^ GetHashCode( second ) ^ GetHashCode( third );
    }
 
    private int GetHashCode( object obj )
    {
        return obj != null ? obj.GetHashCode() : 0;
    }
}

Friday, June 23, 2006

csharpformat test

This is just a test post of source code using the http://www.manoli.net/csharpformat/format.aspx functionality. I also changed the blogger template used since the last templated didn’t show source code too well given the available pixel width. The exercise highlighted how disappointed I am with Google and what they haven’t done with blogger. It seems dead in the water. The original thought with going with blogger is that surely Google would do wonderful things with it in the future since they must have bought it for a good reason. Hmmm.. maybe not.

/// <summary>
/// Initializes a new instance of the <see cref="Triplet"/> class.
/// </summary>
public Triplet( object first, object second, object third )
{
    this.first = first;
    this.second = second;
    this.third = third;
}