tyler butler

LINQ Confusion

I find myself using LINQ a lot in my C# code these days. I use collections all over the place, and there’s no doubt that LINQ makes sorting and slicing collections a lot simpler code-wise.

In my most recent weekend project, I need to randomly sort a list of cards, which are represented by an Action class. After some quick searching, I found some articles that indicated the best way to do this would be to sort the list by random GUID. This makes sense, though I certainly wouldn’t have thought of it on my own.

The examples given all worked, but not with my lists… With the following code, the compiler spits out several errors:

List<Action> cards = new List<Action>();
cards.Add( new OneCattle() );
cards.Sort( a => Guid.NewGuid() ).ToList<Action>();

Error    1    Delegate 'System.Comparison<agricola.Action>' does not take '1' arguments
Error    2    Cannot convert lambda expression to type 'System.Collections.Generic.IComparer<agricola.Action>' because it is not a delegate type
Error    3    Cannot implicitly convert type 'System.Guid' to 'int'
Error    4    Cannot convert lambda expression to delegate type 'System.Comparison<agricola.Action>' because some of the return types in the block are not implicitly convertible to the delegate return type

However, using a more explicit LINQ query without a lambda expression seems to work fine:

var q = from a in cards
        orderby Guid.NewGuid()
        select a;
List<Action> r = q.ToList<Action>();

Anybody know why this is? I haven’t wrapped my head around lambda expressions and the theory behind LINQ to understand what the root cause is…

Commercials Suck

This article, titled “Give Us a Commercial Break!” from the Wall Street Journal is way off the mark in my opinion. The article states that TV shows are written with commercials in mind and that watching them without commercials changes them. That in and of itself I can’t argue with. But I do take issue with the implication that this is uniformly bad.

There are two core arguments in the article:

  1. TV shows are written with commercials specifically in mind, and removing them completely interrupts the pacing of the show.
  2. Viewers actually like shows with ads better.

For argument number one, it’s obvious that writers take commercial breaks into consideration when writing TV shows. However, in their DVD counterparts, the breaks are preserved as scene changes. These can seem rather abrupt, and I think this points to an alternative solution: slightly longer breaks for scene changes that are replacing commercial breaks. If we assume the normal scene change is a second, then imagine that the commercial-break-replacement scene change is three seconds. You can simulate this suggestion by hitting pause for three seconds – I think you’ll be surprised at the results. I think you’ll agree that this is uniformly better than ads.

For argument number two, I can’t refute the research. But there is a quote from the article that is completely asinine in my opinion:

From an audience member’s perspective, they are what makes network television social. We use the commercial breaks to talk amongst ourselves, to take bets on the J.D./Elliot situation and to decide that no one ever really dies on “Lost.”

Say what? That we need commercial breaks to be social is ridiculous. In this day and age, we have ready access to the Pause button, and it’s a far more useful tool for fostering discussion while watching TV. Elizabeth and I have been watching quite a few documentaries lately, and we pause quite often to talk about whether or not we agree with what’s being said. I agree that adding discussion and dialog while viewing a show is positive (there’s a reason fans get together to watch episodes of their favorite shows), but I think people use the commercial breaks because they’re there, not because they need them in order to have that conversation successfully.

I hate ads in all forms (though I can appreciate particularly clever or well- done ones), so I am definitely biased here. But seriously… there’s a reason DVD copies of shows sell so well, and it isn’t because people are dying to own season one of “Scrubs” for eternity…

Site Move and Redesign

The server that is currently hosting the SharePoint version of tylerbutler.com is being decommissioned. Unfortunately, I wasn’t given much notice about this so I have not been able to secure an alternative SharePoint-ready location at Microsoft to host the site. In the meantime I’ve used this opportunity to move the site over to WordPress, and I’ve refreshed the look and feel. Hopefully this will be temporary, since I intend to rebuild the site on the new version of SharePoint once it’s publicly available. But in the meantime, WordPress is serving my needs.

The main www address should be redirecting to blog.tylerbutler.com as soon as the DNS changes propogate. The main RSS feed should be switched over, but I have not yet moved the others. Regardless, though, you shouldn’t notice any differences since I’m using FeedBurner.

SharePoint Updates

We’ve changed the way we’re managing and releasing updates here in the SharePoint team. This is all very good news. It makes things more manageable internally for us, which translates into quicker, more effective turnaround on issues, but it also means that updates and patches will be much more predictable, so you can plan around those dates more effectively. There is still recourse for you if you have an absolutely critical issue that needs to be resolved ASAP.

More details on this SharePoint blog post and KB article 953878.

But Why? #0: But why, "But Why?"

I love hearing stories. When I was growing up I used to love when people would visit and my Dad would tell some of his stories. Even though I had heard most of them a thousand times, it was awesome to sit back and watch other people experience them for the first time. I also read a lot of stories growing up, and I developed a special love for short stories in particular (I especially like O. Henry).

While I was in college, I discovered a site that I have since lost many hours of my life to – folklore.org. It’s a site put together by Andy Hertzfeld (not to be confused with Don Hertzfeldt of Rejected fame), and contains “anecdotes about the development of Apple’s original Macintosh computer, and the people who created it.” It is incredible – it combines my love of stories with a topic I find interesting – the early days of personal computing. Best of all, the stories there are written by the people who experienced it, and often contain a healthy dose of humor and humanity. But behind that, there’s some cool technical details about the challenges the engineers faced, and why some of the decisions got made the way they did. I find that part of it utterly spellbinding.

I’ve been on the lookout for other sites like this for other tech companies, like Atari or even Microsoft. The closest I’ve found for Atari is DadHacker.com, written by a guy who worked for Atari back in the day. His blog is interesting in a variety of ways, but I particularly like his Atari posts. In fact, his post titled Donkey Kong and Me was what got him into my RSS reader permanently. It’s good – you should read it.

I actually work with a developer who was also on the team that developed Clippy, and I’ve heard some interesting stories for him about what that was like. Maybe I’ll try to convince him to write up some of his experiences… I am sure there are some more great stories out there… If you know of some sites, please do point me to them.

Because I find this stuff so interesting, I thought it would be good to start chronicling some of the stuff I know about because I’ve been working on SharePoint. Thus, I plan to write a series titled “But Why?” about various SharePoint features that I either worked on or have been exposed to, and why they behave the way they do. These posts will be one part SharePoint history, one part storytelling, and if I do it right, will pull back the curtain a bit so you can see just why things wound up the way they did.

But first, some disclaimers: These posts are my own thoughts and opinions, and do not reflect those of Microsoft or of anyone else who works/worked on SharePoint. Also, my memory may be fuzzy and blatantly incorrect about some things, so everything should be viewed through that lens. Finally, you shouldn’t expect these posts to be as interesting as anything you read on folklore.org.