December 2005 - Posts

Off topic: Best Albums of 2005

  1. Anthony and The Johnsons – I am a Bird Now
    I am a Bird now was released back in January, and it has been on heavy rotation on my iPod ever since. Anthony has a voice like the late, great Nina Simone who had a deep, masculine voice. This is a striking coincidence on songs such as “For Today I am a Boy” which is about the travails of transgender confusion with its heartbreaking line “One day I’ll grow up to be a beautiful woman, but for now I am a boy”. Musical highlights: My Lady Story, Hope There’s Someone


  2. Arcade Fire – Funeral
    Funeral is a stunningly brilliant album, filled to the rim with emotional intensity. The Arcade Fire blends the sounds from great bands from the 1980s post-punk scene, The Pixies and Roxy Music to name a few, to create their own, new and refreshing soundscape. The album was released in Canada in 2004, but it didn’t get a proper European release until this year. Musical highlights: Neighborhood #1 - #4.

  3. My Morning Jacket - Z
    After two releases that didn’t really appeal to me, My Morning Jacket rises like a phoenix with Z with an entirely new sound. The music is spontaneous and doesn’t seem to follow any conventional musical patterns. A pleasant surprise. Musical highlights: Wordless Chorus, Anytime



  4. Kate Bush – Aerial
    Kate Bush has always gone her own way, and her “comeback” this year is no exception. The double album is musically expansive, where everything from birdsong to eighties inspired synths and jazz elements blend into a lush musical journey. The lyrics are eerie, deeply personal and they grab you right from the beginning. Musical highlights: A Sky of Honey (The suite which makes up CD 2).


  5. Sigur Rós – Takk
    Takk is an album with quite, yet still noisy music that is pure bliss. I can’t understand a word they’re singing since the lyrics are in either Icelandic or in the fabricated Hopelandish language, but this makes the album even more wonderful as the beautiful vocals come across as musical instruments. Musical highlight: Hoppipolla, Glósóli



  6. The Magic Numbers – The Magic Numbers
    The Magic Numbers is the most perfect pop record of the year with great lyrics, incredible hooks and great SoCal style harmonies. Musical highlights: Forever Lost, Love Me Like You, Love Is a Game





  7. Bell Orchestre – Recording a Tape The Colour of Light
    Bell Orchestre is a spin-off from many bands in the Montréal scene, with members from bands like Arcade Fire. Their music can best be describes as a mash of chamber music and post punk. The album isn’t easily accessible, but once you get your ears around it you’re sold. Musical highlights: Les Lumineres pt. 1




  8. Little Brother – The Minstrel Show
    While you’ll probably have to browse the hip-hop section of your local record store to find this album, this album is the opposite of your regular rap album. The Minstrel Show is a concept album centered on a television show which acts as a metaphor for everything that is wrong with today’s mainstream hip hop. Musical highlights: The experience as a whole, which is rare with hip hop albums these days.



  9. Sufjan Stevens – Illinoise
    Illinoise is a sprawling musical celebration, which encompasses a vast set of musical styles, blended into magical, sophisticated arrangements. This is a great album. Musical highlights: Come Feel The Illinoise




  10. Dangerdoom – The Mouse and The Mask
    The collaboration between MF Doom and production genius Danger Mouse has resulted in a playful album that is heavy on novel details in both rhyme and rhythm. Musical highlights: Sofa King, Aqua Teen Hunger Force




  11. Death Cab for Cutie – Plans
  12. Devendra Banhart – Cripple Crow
  13. Fat Freddie’s Drop – Based on a True Story
  14. Brian Eno – Another Day on Earth
  15. Jaga Jazzist – What We Must
  16. Iron & Wine and Calexico – In the Reins (EP)
  17. John Legend – Get Lifted
  18. Kari Bremnes – Over en by
  19. M.i.A. - Arular
  20. Jamie Lidell – Multiply
  21. Roots Manuva – Awfully Deep
  22. Archer Prewitt – Wilderness
  23. Iron & Wine – Woman King (EP)
  24. Moneybrother – To Die Alone
  25. Amadou et Mariam – Dimance à Bamako
  26. Steve Reid Ensemble – Sprits Walk
  27. Common – Be
  28. Porn Sword Tobacco – Explains Freedom
  29. …and You Will Know Us By The Trail of Dead – Worlds Apart
  30. Emiliana Torrini – Fisherman’s Woman
  31. Edan – Beauty and The Beat
  32. Low – The Great Destoyer
  33. The Herbaliser – Take London
  34. VHS or Beta – Night on Fire
  35. Andrew Bird – And The Mysterious Production of Eggs
  36. Boards of Canada – Campfire Headphase
  37. Pat Metheny – The Way Up
  38. Quasimoto – The Further Adventures of Lord Quas
  39. Clap Your Hands and Say Yeah! – Clap Your Hands and Say Yeah!
  40. The Fiery Furnaces – Rehearsing My Choir
  41. Harold Budd & Eraldo Bernocchi – Fragments Form The Inside
  42. The Dandy Warhols – Oddatorium or Warlords of Mars
  43. Harmonic 33 – Music for Film, Television and Radio vol. 1
  44. Broadcast – Tender Buttons
  45. Depeche Mode – Playing the Angle
  46. M83 – Before the Dawn Heals Us
  47. Sinéad O’Connor – Throw Down Your Arms
  48. Buck 65 – Secret House Against The World
  49. Nostalgia 77 – The Garden
  50. The Perceptionists – Black Dialogue

Comparing cloned objects

My co-worker Kjell-Sverre Jerijærvi has posted a cool follow up to my “How to: Deep clone any serializable object” post. His example shows a generic IsClone method which uses serialization and MD5-hashing to determine whether two different object instances are clones of each other. Nice one, Kjell-Sverre.

DuckUnit

Some weeks ago I downloaded the new beta of Test Driven .NET. As you might know the beta is available through Folder Share, which basically is a peer to peer network. Trying to support Jamie’s excellent tool I kept the share open to help distribute Test Driven .NET. A cool side-effect from this is that I automatically get all the latest files downloaded to my computer. I’ve got my shared folder in a sub folder beneath My Documents, and my information client of choice; Jet Brains’ excellent Omea Pro keeps track of changes to files in My Documents. Earlier today I noticed that a mysterious, new folder named DuckUnit had appeared. When I opened the folder to take a closer look at what it was I discovered the creator of Test Driven .NET, Jamie Cansdale was up to something again. DuckUnit is a testing framework that let’s you specify units test by applying a custom XML code comment named test to your methods. For example:

    /// <test x="1" y="2" z="3">6</test> 
public int Sum(int x, int y, int z)
{
return x + y + z;
}

The attributes correspond to the arguments of the method, and the inner text of the element to the expected result. The framework also lets you define your test data in separate XML documents, using the standard include directive:

    
    /// <include file="PrimeTests.xml" path="tests/test/" />
    static bool IsPrime(int num)
    {
     int max = (int)Math.Sqrt(num) + 1;
     for (int count = 2; count < max; count++)
     {
      if (num % count == 0) return false;
     }
     return true;
    }

The need to have some arbitrary test data to use within your unit tests is common. Usually I’ve restored to having DataSets with test data or serialized mock objects stored as XML within my test projects. I really like the idea of being able to inject test data into my unit tests in a declarative fashion. Especially when you can use the include statement to separate the test data from the actual test. I’d really like to see some examples of how to use more complex types as arguments for the test methods, but a primitives only solution is a good start. Maybe parameterless unit test soon will be a relic of days gone by?

Dynamic Methods and Humane Interfaces

One of the key differences between C-style languages such as C# or Java and Ruby is how libraries are designed. The Ruby crowd has coined the term “Humane Interface” describing their style of defining class interfaces. A good example is Ruby’s List type which exposes a whooping 78 instance methods, while .NET’s ArrayList class has less than twenty if you leave out the overloads. The generic List<> in .NET 2.0 has some more, but still the methods are all low-level. A good example of syntactic sugar in Ruby’s List is the flatten method which flattens a multi-dimensional array.

[1,2,[3,4,[5,6],7],8].flatten => [1, 2, 3, 4, 5, 6, 7, 8]

When I teach developers about refactoring, I often use an example I’ve borrowed from Joshua Kerievsky’s Refactoring to Patterns book to show how code can be more readable or more humane if you like; November(20, 2004) where November is a public static method accepting the day of month and the year as its arguments. The November method communicates its behavior better compared to new DateTime(2004, 11, 20) which requires you to have knowledge of the System.DateTime constructor.

Examples like the one above might seem a bit over the top, but successful Ruby frameworks such as Ruby on Rails have similar methods that have been essential to the libraries success. For instance; Ruby on Rails has a pluralize method which gets the plural form of most English nouns. Why would you need such a method? The answer lies in Ruby on Rails convention over configuration philosophy, where instances of a User class are expected to be persisted in a Users table in the database. The pluralize method makes this convention easy to apply.

John Lam has been doing some really interesting experiments with programming Ruby with the CLR, and his latest project is a great example of how Ruby’s humane interface philosophy makes Reflection.Emit, which is one of the least approachable namespaces within the .NET framework, much easier to use.

    create_ruby_method('say_hello') do
ldstr 'Hello, World'
call 'static System.Console.WriteLine(System.String)'
ldc_i4_4
ret
end

Above is an example of how to use his RbDynamicMethod library to create a CLR DynamicMethod from Ruby. Although MSIL still is cryptic to most, being able to write “MSIL code” within the source code is much easier than using OpCodes to emit MSIL code. Below is the same example using the .NET 2.0 Lightweight Code Generation (LCG).

    public class DynamicMethodExample
{
public static void Main(string[] args)
{
DynamicMethod method = new DynamicMethod("SayHello",
typeof(void), new Type[] {}, typeof(DynamicMethodExample), false);
ILGenerator gen = method.GetILGenerator();
gen.Emit(OpCodes.Ldstr, "Hello, World!");
gen.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine",
new Type[] { typeof(string) }));
gen.Emit(OpCodes.Ret);
}
}

The lightweight in LCG has its place. In .NET 1.x you could emit the Hello World part of the above example in three lines of code, but you would typically need approximately 10 more lines of code to setup the classes needed to do this. The LCG is a huge improvement, but I still find John’s MSIL code more appealing than using reflection to get hold of MethodInfo’s and similar.

Another example of how class interfaces can be more humane is .NET’s EventLog class which throws an ArgumentException with information on how to resolve the error when the class is used without being properly configured. Such a message gives developers instant clues on what might be wrong, and can save them hours of mucking about with the debugger.

The syntactic sugar added to C# 3.0 and Visual Basic 9 in particular make the languages more expressive, and the LINQ framework provides a great abstractions allowing developers to do complex operation in just one or two lines of code. These new additions to the .NET development environment make the general developing experience more humane. Humane interfaces are a trend that reaches way beyond the small Ruby community, and you should always look for options to make your class interface more humane. Even if your core classes might require more maintenance over time, the client code will be easier to maintain since the code base will be much smaller, more expressive and readable.

Dating Patterns

I came across a book called Dating Patterns by Norwegian writer Solveig Haugeland at Amazon, and it is the ultimate Christmas gift idea for any geek singleton. It is unlikely that I’ll practice any of the patterns in the book since my significant other strongly disapproves “multi threading”, but I’ve been through many of them unconsciously during my bachelor days. I tried to come across a Cary Grant Helper, but at the end of the day I probably was more of a Half Bad Boy Plus Protocol. Thinking back, I’ve probably got plenty of material for a dating anti-patterns book of my own.