Extension Methods

Since we are using Silverlight on this new project I am working on, we are doing our development in .NET 3.5. One of the new features in .NET 3.5 is Extension Methods. When I first saw this I figured it was a nice feature, but I didn’t know when I would use it. Today I wrote a couple. I figure there’s probably a couple reasons you would create an Extension Method: (a) You see you are performing the same coding routine in multiple places, and it would be nice if you could replace it with less code, and (b) there’s a method you always wished was on one of the built in .NET types -- something like String.ToUpperCase() or something along those lines. The Extension Methods I wrote today fell into the first category. We have a lot of places in our code where we check if an object is null before progressing.

if (contract == null)
    return;

I wrote a simple IsNull Extension Method that can be applied to any object as long as a reference to my Extension Method namespace is in the using directives.

public static bool IsNull(this object source)
{
    return source == null;
}

It’s very simple, and only saves a little typing, but it looks nicer to have the following

if (contract.IsNull())
    return;

We also tend to have a lot of code that checks if a List is not null and also isn’t empty

if (titleIds == null || titleIds.Count == 0)
    return;

For this I created an IsNullOrEmpty Extension Method

public static bool IsNullOrEmpty<T>(this List<T> source)
{
    return ((source == null) || (source.Count == 0));
}

This way you can write the code as

if (titleIds.IsNullOrEmpty())
    return;

These are the only Extension Methods I’ve written so far, but I can think of another one that would be useful and would fall into the second category of why you would write Extension Methods. Let’s say the Generic List of Integer TitleIds I had in the previous example had a couple duplicates, it would be nice to be able to say

titleIds.RemoveDuplicates();

|

STP

Paige and I went to the STP (Stone Temple Pilots) concert last night at Verizon Wireless Amphitheatre in Alpharetta, GA.

Our night started off interesting. We decided to drop by P. F. Chang’s to eat some appetizers and have a couple drinks before heading to the concert. We generally don’t eat at chain restaurants, aside from the occasional visit to Ted’s Montana Grill for a bison burger; but there’s not much choice in Alpharetta when it comes to restaurants except for chains. When we arrived at P. F. Chang’s, we saw there was a long wait, so we headed up to the bar area. Unfortunately we could only find one seat at the bar, so Paige sat down while we ordered drinks. The manager walked by and started talking with us, saying it was kind of crowded due to people dropping by before the STP concert, we told him we were heading there and wanted to grab something to eat before going. He said the wait was around an hour, but he would see what he could do. Maybe 15 minutes later he comes back and directs us over to a table. Then he proceeds to provide us with a card for a free appetizer on our next visit, and also said one of our appetizers with our meal would be on the house. Paige and I just looked at each other wondering what we did to deserve this. We felt bad that we were only eating appetizers, not exactly spending a lot of money, but I did end up giving the server a 100% tip, and we plan on writing in to P. F. Chang’s to let them know how great we were treated.

We arrived at the amphitheatre in time to see one of the opening acts, Black Leather Motorcycle Club. We got our double Jack and Coke and headed down to the pit area, where we ended up running into some friends. Once that act was over I headed back and got us two more drinks and got back in time for STP to start. I saw STP a long time ago, probably 94 - 95, when they opened for Butthole Surfers. I think that concert was a little better than this one, they just had more energy. Paige and I both thought that Scott Weiland performed the STP songs better when we saw the Velvet Revolver tour earlier in the year. This show wasn’t bad, it just didn’t have any stand out performances. It was great to see STP again, they do have great music, and hopefully Scott will hang around long enough to record another album.
|

Styx/Boston

Paige and I went to the Styx/Boston concert last night in Alpharetta, GA, at the Verizon Wireless Amphitheatre. Styx was the opening band, we came in after a couple songs, but caught a lot of their good songs, so that was fine. Boston played for probably an hour and a half, and it was pretty rockin. They are both great bands to see live. you should see them if you get a chance, even if they don’t have all the original members.
|

Visual Studio Error: "Some of the properties associated with the solution could not be read."

Something happened when I created the Visual Studio .NET 2008 Solution for my Executive View project and checked it into Team System. After it was checked in, I, and the other developer, would receive the following error when opening the solution: “Some of the properties associated with the solution could not be read.”

It took a little digging, but once I looked at the solution file in Notepad++, I saw that there was a duplicate GlobalSection(TeamFoundationVersionControl) = preSolution section. It’s the section that contains all of the parameters prefixed with Scc*. If you delete the duplicate selection it will fix the error.
|

Starting New Project At Work

A few months back I was involved in developing a prototype of an Executive View application, using WPF technology. I wasn’t the biggest fan of the project, mainly due to us using Tangerine, a pre-developed application from Infragistics. While it did help us get the prototype out the door in a timely fashion, I didn’t want us to go the route of just building on top of that application. Luckily we didn’t go that route. It was decided we could use Tangerine as a reference application, which is what I was pulling for from the beginning.

This week will mark the first iteration of The Executive View development. We are doing it in .NET 3.5, with a Silverlight front end. It will be a nice diversion from the project I was working on, which will be nice. I’m not the biggest fan of Silverlight development, mainly because here I am trying to get out of Microsoft development all together, and I’m going to be learning a totally new development environment. At the same time I guess it is pretty cool to be developing using the newest, cutting-edge technology. We’ll see how it goes.
|

Vacation Planning

Paige and I spent the evening planning our next vacation, which we will be taking the end of September, and beginning of October. We are going on another trip to the South West, this time adding in a couple stops we haven’t done before.

We plan on starting off at The Enchantment Resort in Sedona, Arizona. This is the resort we stayed at on our previous trip. It’s a beautiful place to stay, so we are happy to be staying there again. We plan on doing a bit more exploring this time, and also would like to head out on a photography jeep tour, getting to use our new cameras (although we both plan on bringing our old point-and-shoot cameras too, can never be too careful).

We will be heading to The Grand Canyon once we are done in Sedona. We plan on staying 1 day there.

We will head to Monument Valley, Utah, after that. This will be another 1 day visit.

We will spend a couple days in Albuquerque, New Mexico, after that. We are coinciding our trip with the 2008 Hot Air Baloon Fiesta, which should be really cool, and a great photo experience.

We will end our trip with a couple day stay in our favorite place, Santa Fe, New Mexico.

This vacation will be a little different than our others, due to the fact that we are traveling around and doing so much, but it should hopefully be lots of fun.
|

Lonely Werewolf Girl

Most of the time I research a book before I purchase it if it’s from an author I am unfamiliar with, but a while back as I was perusing the shelves at Barnes & Noble I came across a book that caught my eye: “Lonely Werewolf Girl”, by Martin Millar.

25910892

The beautiful illustration on the front caught my eye, so I took a closer look. I am a fan of stories that deal with Werewolves or Vampires, plus this book appeared to have a bit of humor thrown in too; so I went ahead and purchased it.

When I started reading it there was one thing I found weird, the length of the chapters. Now, this story takes place in Scotland and in London, and jumps around between 5 or 6 different story lines, so I understand having new chapters for each story line, but most of the chapters averaged 1 - 2 pages, with the longest chapter being probably 5 - 6 pages. The book is 558 pages and comes in at 236 chapters. Usually when I read a book I try to read a chapter or two an evening, with this that would have taken a couple minutes.

The story revolves around a werewolf clan whose leader had just passed away. Two brother werewolves from the clan want to try for the Thaneship, but the voting by the council doesn’t favor either brother to victory. There are a couple werewolves in the clan that weren’t present for the voting, having moved off to London to start their own lives. The story revolves around these other family members, the two brothers battling, killing, and doing anything else they can to get the vote to go their way, a fire elemental queen that is obsessed with fashion, her crazy niece, and a couple college students caught in the middle. Throw in a guild of humans that hunt werewolves, and you have a pretty good story. Kalix, the youngest werewolf, is the main character this story revolves around, but most characters get equal treatment.

I’m glad I picked up this book, and will look out for other books by this author, it’s a great read.
|