Just trying to make sense of things...

PDC 2008 - Bad Connectivity

Monday, 27 October 2008 10:56 by jordan.terrell

Unfortunately, I cannot get online thru the Microsoft provided WiFi here at the PDC.  To make matters worse, my hotel has pay-only Internet access.  As a result I will not be posting any blog entries, nor will I be doing any live blogging.  Stay tuned though - I will be posting day summaries when I get back to the land of ubiquitous internet access. (In case you were wondering, I'm using the Internet kiosks here at the PDC to post this - not very useful when you are in sessions)

Categories:   Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

PDC 2008 Blogging

Tuesday, 21 October 2008 14:53 by jordan.terrell

When I went to the 2005 PDC, I was going to try to blog during the conference, but at the time I wasn’t very diligent in creating content for my blog on any kind of semi-regular basis.  As a result, over the past few weeks I’ve been debating whether or not I would blog during the PDC this year.  The media lacked the kind of “live” coverage that would make it very engaging.

Well, I just found something that will change that: Cover It Live

The platform is really engaging, very simple for the blogger (me) to figure out, and it is probably what will keep me going during the conference.  Here’s what it will look like for someone following along.

I hope some of my few readers interested in such things will follow along – and feel free to ask questions as well.  Of course, I will be at the mercy of my laptop’s batteries, as well as wireless internet access (which historically hasn’t been so great), but I will do my best to bring some interesting content to the live blog.

I will post information on this blog with links to how you can “tune in” when we are closer the the PDC 2008 event.

Categories:   Programming
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

“Steak Restaurants Near Staples Center Los Angeles”

Monday, 20 October 2008 15:31 by jordan.terrell

Amazing!  Three years ago I went to the 2005 Professional Developers Conference (PDC) in Los Angeles.  One of the nights my manager took me to a really good steak house, and since I’m going again this year I thought I might check it out again.

One small problem – I didn’t remember the name of the place.  I just knew that it was near the Staples Center.  When I searched for it on Google, it was the second one on the list.

More and more I’m amazed at how well Google can shred the text of your search into meaningful information.

Tags:   , ,
Categories:   General
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

“Entering the Stronghold”

Thursday, 16 October 2008 10:31 by jordan.terrell

This is a bit off topic for me, but it is truly a rare thing to find a song, especially one that was put together by tracking in on a computer, that you just can’t stop listening too – and be just as excited to hear it as you did the first time.  Personally, I really like classical songs that have been remixed, or have a very modern or almost techno sound to them – yet still remain true to their classical heritage.

The reason I bring this up is because I’ve found one of those songs that I can’t stop listening to:

Entering the Stronghold

You don’t have to pay to listen to it, although I would gladly do so.  Enjoy!

Categories:   General
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

Disturbing On So Many Levels

Friday, 3 October 2008 13:57 by jordan.terrell

That’s all that needs to be said:

Categories:   Programming | .NET
Actions:   E-mail | | Permalink | Comments (0) | Comment RSSRSS comment feed

LINQ: Distinct() does not work as expected

Thursday, 2 October 2008 10:20 by jordan.terrell

A few days ago I was using LINQ to filter a distinct (only unique items) list of custom objects.  I needed the distinction to be based on a property of type System.String.  Prior to this, I have never used or looked at the Distinct query operator - thus I expected it to have overloads that let me pass in a selector (Func<T, TRet>) to select the property to make the distinction on.

Unfortunately, it has no such overload.

However, what it did have was an overload that took an IEqualityComparer<T>.  As much as that felt like a cop-out (not a very LINQ-ish approach), I figured it would have to do the job.  There was one other overload that basically defaulted to EqualityComparer<T>.Default - this goes through a series of type checks to determine the best comparer for the type T being compared.  If the type T implements the IEquatable<T> interface, it will use that for the comparison.  Great!  I'll just implement that interface on my custom type, and be on my way!

Not so fast! It didn't work - for some reason it never invoked the IEquatable<T>.Equals method implemented on my custom type.  My next step was to implement as custom IEqualityComparer<T> to make the comparison based on the the property value.

That didn't work either! At this point I was quite confused, and then out of sheer desperation I put a breakpoint on the other method defined on IEqualityComparer<T>: GetHashCode.

"You've got to be kidding me!" - I believe those were the words going through my mind.  The Distinct query operator uses hash codes provided by an IEqualityComparer<T> to determine the distinct set of items.  Upon further inspection, the Distinct operator doesn't really use GetHashCode, it defers to another Set class to filter the items - that class uses the GetHashCode method.

Not what I expected.  Needless to say I was a bit disappointed.  Not only was there not an standard overload for me to pass in a selection lambda, but now I couldn't even use the Equals method on IEquatable<T> OR IEqualityComparer<T>!

I wasn't about to implement a custom GetHashCode method - I believe the annotations in the book Framework Design Guidelines basically says that the current implementation of GetHashCode is flawed.  Plus, for it to work in my case I would have to return the hash code for the property I wanted compared, not the hash code for the custom type.  All of this left a very sour taste in my mouth.

I did find an alternative though - using a combination of the GroupBy, First, and Select query operators, I was able to get what I wanted:

   1: var distinctItems = items
   2:     .GroupBy(x => x.PropertyToCompare)
   3:     .Select(x => x.First());


It looses quite a bit in meaning, but it accomplishes the end goal.  At some point I think I'm going to create an Extension Method that adds another Distinct() overload that takes a selection lambda - something that should have been there to being with!

Tags:   ,
Categories:   .NET | Programming
Actions:   E-mail | | Permalink | Comments (7) | Comment RSSRSS comment feed