Wednesday 26 September 2007

Installing Infragistics NetAdvantage on Vista

Note to self: To do this successfully, you need to turn off UAC. If you don't it won't install properly.

Monday 17 September 2007

Take a bath...

From Pi:


SOL Remember Archimedes of Syracuse? The King asks Archimedes to determine if a present he's received was actually solid gold. Unsolved problem at the time. It tortures the great Greek mathematician for weeks. Insomnia haunts him and he twists and turns on his bed for nights on end. Finally, his equally exhausted wife, she's forced to share a bed with this genius, convinces him to take a bath, to relax. While stepping into the tub he observes the bathwater rise as he enters. Displacement. A way to determine volume. And thus, a way to determine density, weight over volume. And thus, Archimedes solves the problem. He screams "Eureka!"—Greek for "I found it!"—and is so overwhelmed he runs dripping naked through the streets to the King's castle to report his discovery. Now, what's the moral of the story.
MAXThat a breakthrough will come...
SOL Wrong. The point of the story is the wife. Listen to your wife, she will give you perspective. Meaning, you need a break, Max, you have to take a bath, otherwise you'll get nowhere. There will be no order, only chaos. Go home and take a bath.

I had an Archimedes moment over the weekend. I'd been struggling to work out the problem all last week. Came in this morning and got it nailed in a few hours.

Take a bath ;)

Enum

inspired by Enum, here's my version... it still needs to work with resources, but works otherwise.


public static class Enum <T>
{

public static T Parse ( string name )
{
return ( T ) Enum.Parse ( typeof ( T ), name );
}

public static IEnumerable < T > GetValues ( )
{
foreach ( T value in Enum.GetValues ( typeof ( T ) ) )
{
yield return value;
}
}


public static IEnumerable<AttributeType> GetAttributes <AttributeType> ( T value ) where AttributeType : Attribute
{
FieldInfo fieldInfo = typeof ( T ).GetField ( value.ToString ( ) );


if (fieldInfo != null)
{
foreach ( object customAttribute in fieldInfo.GetCustomAttributes ( typeof ( AttributeType ), false ) )
{
yield return customAttribute as AttributeType;
}
}
}

public static IList<AttributeType> GetAttributeList <AttributeType> ( T value ) where AttributeType : Attribute
{
return new List<AttributeType> ( GetAttributes<AttributeType> ( value ) );
}

public static string GetDescription( T value )
{
IList< DescriptionAttribute > attributeList = GetAttributeList<DescriptionAttribute> ( value );

if (attributeList.Count < 1)
return value.ToString();

return attributeList[ 0 ].Description;
}
}

Sunday 9 September 2007

Tools

Programmers love tools - just to write a program, you need at least three: text editor; compiler; and, a linker - and that's excluding the computer and the operating system!
However, as with any other craft, there are certain rules you need to follow when using tools:
  1. Use the right tool for the job
    Obviously, you wouldn't try to edit your text with a linker, but even-so...
  2. Know how to use your tools
    The same way you can take your fingers using a circular saw incorrectly, you can run your project into a lot of trouble by abusing your tools.
  3. Use the best tools you can get your hands on
    It's not just about cost - you can get good and cheap tools, but you can also get expensive shit.
  4. Look after your tools
    You main tool as a programmer is your computer. Keep it clean and sharp and it'll be a lot easier to use.