Thursday, December 29, 2011

LINQ Review


A little review for those that never really embraced the beginnings of LINQ:

LINQ is an acronym for Language Integrated Query which allows you to write structured type-safe queries over object collections. It was new as of .NET 3.0 in C#. The basic LINQ query can be run over any collection implementing IEnumerable<> and are compile-type checked. The core namespaces supporting LINQ are System.Linq and System.Linq.Expressions in the Systems.Core assembly.
The basic units of LINQ are sequences and elements. A sequence is any object that implements the generic IEnumerable interface and an element is each item in the sequence.
string[] michael = { "Jon", "Mikal", "Brad" };
In this example Michael is the sequence and Jon, Brad and Mikal are the elements.
A query operator is a method that transforms a sequence. In the Enumerable class in System.Linq there are around 40 query operators, all implemented as static extension methods, called standard query operators. A query is an expression that transforms sequences with query operators. The most basic queries have one input sequences and one operator. In the following example, the Where operator is applied on a simple array to extract those names that have at least 4 letters:
string[] michael = { "Jon", "Mikal", "Brad" };
       IEnumerable<string> filtered = Enumerable.Where( michael, m => m.Length >= 4 );

       foreach ( var item in filtered )
       {
              Console.WriteLine( item + "|" );  // Mikal|Brad|
       }

This query could further be shortened by implicitly typing michael:
var filtered = michael.Where( m => m.Length >= 4 );
Most query operators take a lambda expression as an argument. This expression helps shape the query, the lambda expression from above is:
m => m.Length >= 4
                The input argument, in this case m corresponds to an input element. In the above example the input argument represents the names in the array and is of type string. This operator, Where, requires that the lambda expression return a boolean value which if true in this case means the element should be included in the output sequence. These types of queries are commonly referred to as lambda queries. There is also in C# a special syntax for writing these queries called query comprehension syntax. The above lambda query can be re-written in query comprehension syntax as follows:
       IEnumerable<string> filtered = from m in michael
                                     where m.Length >= 4
                                     select m;

                Both types of queries work together to provide a much easier way of iterating elements in a sequence.               

Tuesday, December 27, 2011

Scrum is like Angry Birds

So I got two more Angry Bird stuffed animals this Christmas because I have an infatuation for them, I think the noise is like a baby laugh, it’s one of those things that you can’t help smiling to, which is why the non-noise making ones bore me. I started thinking, while smoking the dinner ham this weekend, how Angry Birds is much like Agile and the Scrum process in so many ways.

The Agile chicken and pig story basically goes like this: A pig and a chicken are walking down the road, The chicken says, “Hey Pig, I was thinking we should open a restaurant!”. Pig replies, “Hmm, maybe, what would we call it?”. The chicken responds, “How about ‘ham-n-eggs’?”. The pig thinks for a moment and says, “No thanks. I’d be committed, but you’d only be involved!”



This fable helps provide an analogy to define the two main members of any type of project team but specifically in the Agile Scrum management system.

The pigs are totally committed to the project and accountable for its outcome. They have built the wood/glass/stone castles to protect and shelter themselves and store their riches in. Mike Cohn refers to pigs as “Having their bacon on the line.”. Pigs are the people who “do” the work (Not to say chickens don’t do any work).

The chickens (Angry Birds) who consult on the project and are informed of its progress. A chicken is someone who has something to gain by the pigs performing but in the end do not contribute day to day to getting things done.

You could make the same analogies of Angry Birds. This may be why this game has taken off so well. It makes sense in the day-to-day life of most people who do work. The pigs in Angry birds have done the work already. They have built the houses or are building their houses and work really hard to build tougher and tougher houses. Now obviously the chickens are not trying to tear down the houses in Agile but they are benefitting from the work of the pigs (points in this case). The pigs even get cooked (angry bird bombs) in some cases.

It’s not really a stretch to see the similarities, which is why if you look at the angry birds history it kind of makes sense. The company that created angry birds started with 3 technology students from the Helsinki University of Technology, now called Aalto University School of Science and Technology. They have a strong history in the development industry and their company still uses Agile for all their mobile development today. The originally formed company actually created the first mobile multi-player game in the industry. So it makes sense that they would have developed a game that interacted in a manner they are familiar with.

Now, there are some pigs right now saying, “based on this information why do we need chickens, if they just get in the way and tear things down”. Remember the story again, the chicken came up with the idea in the first place. You have to have chickens, without them there is no need for pigs. Chickens are those ancillary roles that have infrequent involvement in the scrum process but nonetheless, must be accounted for. Chickens are the Stakeholders (customers or vendors for instance) that enable project and who will benefit from the pigs work (Angry Bird points) and the managers (includes Project Managers) who get/keep the environment ready for development. Pigs are your Product Owners (represent the voice of the customer) and are accountable for ensuring the delivers business value. The product owner writes user stories, prioritizes them and adds them to the backlog. The team (developers), and the scrum master who is responsible for removing impediments. The scrum master SHOULD not be the leader but act as a buffer between the team and the distractions of outside day-to-day activities.

Nobody can be a pig and a chicken (Pigkin), here is where Angry Birds really comes into play to help define and separate roles. You can’t build the house and be the one that tears it down. It really provides no benefit to a project to be both a chicken and a pig and in fact may tear it down. Pigkins are one of the hardest lessons for any scrum team to overcome.

Well, I have ranted enough for this week, but if you have any doubts or confusions about the scrum team roles and why they are important, please feel free to come by my desk and squeeze the pig then squeeze the angry bird. It will become very clear, just based on the noises these guys make … I’ll leave the rest for you to decide.

Monday, January 3, 2011

AppFabric "Cannot open Service Control Manager"

Recently we moved from a concept phase with AppFabric to a development phase. The concept testing had been done across several developer boxes all on the same domain on Windows 7. When we moved to an actual server, yet continued development on our boxes, those development servers exist on a different domain. Those domains are resolved in the following fashion for us, xxx-xxx.xx.xx. AppFabric had a real issue resolving this. We could ping it, we could resolve it in many different ways, yet AppFabric could not resolve the host name of xxx-xxx.xx.xx. The final resolution was to use just the server name xxx-xxx and add host entry files. This works beautifully and has allowed us to move on.

I spent days looking for answers on every search engine till I finally hunkered down and just found the resolution. It would not resolve when it was named by IP or DNS. The error I kept seeing was from the title of this blog. In the end, after reviewing and logging some serious stack trace, it looks like the .NET call to new Uri() is not able to resolve "." (dot) names. This sounds like and AppFabric bug I hope they resolve in future versions.

So if you are tracing this down and find this blog entry, and you use "." in your DNS names to cross domains, give this a try.