Updated Life Goals

I was tagged regarding annual goals. I’ll just call them life goals, since I am not going to tie them to a specific year. If I do them right, they will change my life permanently. Of course a goal needs a timetable, so knowing how hectic my Decembers are, I’ll say these should be done 10.5 months from now.

  1. Create More
    I consume a lot of content. Some things will remain strictly consumable for me. Music, television and movies are not something I’m willing to create. Books, articles, blog posts and other forms of writing are something I should create more. I consume them greatly. I probably read too many blog posts, but I’m ok with that. Code is something I should definitely be creating. Sending patches to my favorite open source projects or trying to port them to Win32 are my goals.
  2. Watch Less Television
    I’m a Law and Order addict. I never watched it when it was new. I still don’t watch the original. Criminal Intent and Special Victims Unit are always on and I’ve never seen them. Its 10+season of episodes that always waste my time. I’ll probably also watch less sports too.
  3. Trash ten pounds
    I lost the twenty pounds I gained while my wife was pregnant, but the twenty I gained throughout my 20s are still with me. I’d like to keep some of the weight as muscle and shed the fat, but I think I’d be better at 165 pounds instead of 175 pounds.
  4. Get Out of Debt
    I hate debt. I’ve got the debt-free bug. I want out. I want to owe no one. My family religion even calls debt slavery. "The rich rule over the poor, and the borrower is slave to the lender." (Proverbs 22:7)
    Last year my wife and I paid off the last of our non-housing debt. The ambitious goal this year is to pay off our mortgage. Its a huge goal, but it is one that I am passionate about. Think your house is an investment? Maybe yours is. Mine will never be. Think a house is a good investment? Well, consider you bought in 2003? How is that “good investment” performing for you?

I’m not calling anybody else out. If you read this, consider yourself called. What areas of your life are you currently working to improve?

Two days left until CodeMash

Sing to the tune of “Christmas is coming”

CodeMash is coming
The talks are getting full,
Please check the schedule
For the things that rule.

If you haven’t got the F# skills,
The Scala skills will do,
If you haven’t got the Scala skills,
The God bless you.

OK, that was lame, but I don’t care. I’m really looking forward to the excellent talks at CodeMash. Yes there will be many open spaces, and they will be splendid. The majority of CodeMash is still classic eyes forward sessions. Nearly all of them that I attended last year were brilliant.

I still haven’t picked which talks I am going to see. What talks are you planning to see?

Multimap is Lookup

Breaking the tradition of not giving developers even the most basic of data structures with which to work, Microsoft, in its magnanimous wisdom, chose to include a multimap implementation in the 3.5 version of .NET. This was the same time that it first gave developers a Set implementation too. Its amazing any developers tolerated not having these out of the box with .NET over the years, but I guess making them yourself is the norm for us old C/C++ types.

(I shouldn’t give MSFT such a hard time. Java doesn’t ship a multimap either, you are left to use Apache Commons or Google Collection Library. http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html)

Not wanting to break all traditions, they screwed up on the naming. Calling it a multimap would have been too easy. After all, we don’t call our resizable arrays “vectors” do we? No, we call them Lists. But aren’t Linked Lists something else, well, yes they are, Lists aren’t Linked Lists, and Linked Lists aren’t Lists, at least not in the IList<> of the sense. Enough Ranting.

(http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html v. http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx)

In the System.Core assembly in the System.Linq namespace there is an Interface named ILookup`2. There is an implementation of it called Lookup`2, but you can’t construct it. Yes, as if poor naming weren’t enough, It seems that MSFT doesn’t actually want you to use a multimap. Taking a look at return types and interface definitions, it seems this type exists only to support the Groupby LINQ implementation. Being the lazy programmer that I am, I do not want to write a multimap. The existence of the ToLookup extension method on IEnumerable, tells me that maybe I can get at one of these things.

In this example, assume I have a grocery shopping list which I’ve named mmap so that you remember it is a multimap. I want to organize (key) things in my list according to where I will store it, the fridge or the freezer.

var mmap = (
    new [] {
        new {Key = “Freezer”, Item = “IceCream” },
        new {Key= “Freezer”, Item = “Blueberries”},
        new {Key= “Freezer”, Item=”FCOJ”},
        new {Key = “Fridge”, Item=”Milk”},
        new {Key=”Fridge”, Item=”Yogurt”},
        new {Key = “Fridge”, Item = “Eggs”}
    }
    ).ToLookup(a=>a.Key, b=>b.Item);
foreach(var map in mmap)
{
    Console.WriteLine(map.Key);
    foreach(var val in map)
    {
        Console.WriteLine(“\t”+val);
    }
}

//look’em up by index
Console.WriteLine(mmap[“Freezer”]);
//but that is just an IGrouping<>
foreach(var item in mmap[“Freezer”])
{ Console.Write(item);Console.Write(“\t”); }
Console.WriteLine();

Some things to note:

  • We are exploiting anonymous types, they are very useful here.
  • There is no reason that Key and Item have to be named as such, I just found this most readable.
  • There is no reason Key and Item have to be typed as String. They could be any type, but the key type should support equality comparison for the grouping to function.
  • ToLookup() returns an ILookup`2 and not a Lookup`2.
  • The resulting multimap is immutable, like most things LINQ.

An expert LINQer might say “this is no different than group by”, and at first glance, I’d agree. There is an important difference. Under the hood it is likely that this is implemented exactly the same as group by, but ToLookup returns an ILookup`2. ILookup`2 extends IEnumerable[IGrouping`2]. The latter is what Groupby returns. This is important because the ILookup`2 interface exposes the indexer so that you can get at your map by indexing by key.

I wish I could just new up a Lookup and add items rather than jumping through hoops (see a future post). But I’m happy to never write another multimap implementation again.

Three days left until CodeMash

I’m not just hoping, but I’m expecting to have my mind blown.

Sometimes even open spaces is too structured. The structure is good, but people feel a need to stay on topic. I appreciate this, but I also like the completely unstructured total geek talk that you can get in the hallway. Michael Letterle and Joe O’Brien blew my mind with some conversation last year. I’m sure it will be something else this year, and I can’t wait.

For what are you hoping and expecting at CodeMash? Anything mind blowing?

Four days left until CodeMash

I’m excited to so something weird at CodeMash:

Adding things to the Open Spaces board that I know nothing about! What better way to learn about something and meet people who know those things at the same time. Maybe there will be someone (other than Dan) who knows about writing Brew applications and can tell me that I’m crazy for even thinking about it.

What are you excited to do at CodeMash?