Fluff

A Dearth of Mid-Level Developers

My company is having a very difficult time finding mid-level developers. Our development team isn’t that large, so the number of junior people we can support isn’t that large. In terms of .Net experience, we have 3 relatively junior developers and myself. I’ve done a fair amount of architect work, senior development / team lead stuff, and been doing .Net for about as long as it has been out. That leaves us with a gaping “talent hole” that could be filled by a mid-level developer or two.

The problem, however, is that every resume we see is someone who is definitely very junior or someone claiming to be an architect (who often techs out at lower mid-level). My boss (and I can’t say I blame him) is against hiring someone who thinks too highly of himself and seems unteachable. A certain amount of ego does come with the territory and everyone is trying to get the best job for the most money possible, but people really need to be honest with themselves.

I’ve done a lot of thinking about this and I think that I’ve come to a conclusion on this problem. The reason that we are having such a hard time finding solid mid-level developers is because they are actually very scarce (in relation to the rest of the populace). Hear me out.

Junior developers are – of course – the most plentiful. Every developer who will ever be anything starts out in this rank. However, I believe that the people who will actually become great in this profession move out of this group rather quickly. In talent level, they are my coveted mid-level developers; by experience, they can easily be overlooked as still junior.

Almost two years ago, Jeff Atwood wrote a post on Coding Horror in which he quoted Bill Gates on this subject. I’ll leave you to read the post, but basically someone asked Bill Gates if accumulating experience made programming easier and he said, “No. I think after the first three or four years, it’s pretty cast in concrete whether you’re a good programmer or not”. He goes on from there, but that hits my point.

People who “get it” and have a lot of experience – the “rock stars” that Joel Spolsky writes about – are hard to find. Spolsky claims that you don’t find them easily at all because they are rarely on the market for any amount of time and in essence “hand pick” their jobs.

People who “get it” and don’t have a lot of experience – probably most likely the people I am looking for – are very hard to find because their resumes hide the fact that they are good and are going to be awesome some day.

People who don’t “get it” can have any number of years of experience and they are still not attractive candidates. In the Columbus, Ohio market (where I’m located) there is a relative shortage of developers, so seemingly everyone can find a job. What I’m speculating is that these individuals end up with 7-8 years of experience and think that they should then be able to land a senior job. In my opinion, however, they fall into the category of “poor developer” and shouldn’t be hired into those positions by any reputable company. What may happen is that some consulting firm will pick them up and bill them out at $150.00 an hour as “experts”, but it is really the consulting company’s system that gets them through projects.

(A quick note: I am not saying that anyone who consults is no good. I’ve met several consultants who are of the utmost quality and deserve every penny they make (often they are independent and actually get to keep much of what they bill). However, I’ve also met quite a few consultants who I’d mark as falling into the broad categorization of this post.)

I don’t know what to do about this problem, actually. If you are a good, solid developer who “gets it” and wants to work with the latest and greatest coming out of Redmond, leave me a comment and if we still have positions open at the time, I will personally make sure that your resume gets looked at and unless it is god-awful, I can pretty much guarantee you a phone tech-screening. From there its all you, hotshot.

Linq

Project Euler Problem One

Leonhard Euler, from http://www.crossingwallstreet.com/euler-1000.png(From their website) Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

I decided to take a crack or two at these, even though a trillion people have done these before me (32,022 registered answers as of the time that I’m writing this). My goal is to try to do this in whatever way occurs to me at first, and then to try to solve the problem using some new technique. Over the course of solving these problems, I want to try to dig a little into F#, Ruby, C# 3.0, or whatever seems like it might be cool 🙂

Today, I attack Problem One. I’ve included the answer in the comments, so don’t read on if you don’t want to know.

namespace ProjectEuler
{
    /// <summary>
    /// Problem 1
    /// 05 October 2001
    /// If we list all the natural numbers below 10 
    /// that are multiples of 3 or 5, we get 3, 5, 6 
    /// and 9. The sum of these multiples is 23.
    ///  
    /// Find the sum of all the multiples of 3 or 5 below 1000.
    /// 
    /// The answer is 233168
    /// </summary>
    public class Problem1
    {
        public int SolveProblem()
        {
            int answer = 0;

            for (int i = 1; i < 1000; i++)
            {
                if (IsMultipleOfThreeOrFive(i))
                {
                    answer += i;
                }
            }
            
            return answer;
        }

        public static bool IsMultipleOfThreeOrFive(int number)
        {
            return (((number % 3) == 0) || ((number % 5) == 0));
        }
    }
}

Okay, that was a snoozefest. I was reading in the Pro LINQ book (the one that gave me this post) and I found Enumerable.Range. Do the wonders of LINQ never cease? Enumerable.Range will generate a range of numbers for you so that you don’t have to do a loop. Then, you could use that range to then perform a lambda on (the divisible by 3 or 5 check) and then just sum the remaining list. It turns out that this kind of thing is *exactly* what LINQ will just knock out for you. Check the resulting code.

using System.Linq;
namespace ProjectEuler
{
    /// <summary>
    /// Problem 1
    /// 05 October 2001
    /// If we list all the natural numbers below 10 
    /// that are multiples of 3 or 5, we get 3, 5, 6 
    /// and 9. The sum of these multiples is 23.
    ///  
    /// Find the sum of all the multiples of 3 or 5 below 1000.
    /// 
    /// The answer is 233168
    /// </summary>
    public class Problem1
    {
        public int SolveProblem()
        {
            var problemSet = from i in
                             Enumerable.Range(1, 999)
                             where (((i % 3).Equals(0)) || ((i % 5).Equals(0)))
                             select i;

            return problemSet.Sum();
        }
    }
}

Same answer? Check. Learned and used something new in the process? Check. Looks like I win the nerd prize!

Code Tips

Enumerable.Intersect, Enumerable.Except, and Enumerable.Union

Pro LINQ: Language Integrated Query in C# 2008I love when things come up just in time for me to need them for a project that I’m involved in. Currently, I need to take a bunch of results and find only the intersection of those results. I was contemplating doing some lambdas to compare the lists, but then I was reading Pro LINQ: Language Integrated Query in C# 2008 and I found the Intersect() method. (Note: Thanks to Jeff Meyer for loaning me the book in such a timely fashion.)

The code looks like this:

using System;
using System.Collections.Generic;
using System.Linq;

namespace Linq
{
    class Program
    {
        static void Main(string[] args)
        {
            var listOne = new List<int>() { 1, 2, 3, 4, 5};
            var listTwo = new List<int>() { 3, 4, 5, 6, 7};

            var intIntersect = listOne.Intersect(listTwo);

            foreach (var i in intIntersect)
            {
                Console.WriteLine(i);
            }
        }
    }
}

What is output is

3
4
5

There are two important things to note. First of all, you can use any IEnumerable to perform an Intersect. Secondly, it is important to realize that you are comparing from the first list to the second list. This isn’t important when doing an Intersect(), but lets look at another example.

using System;
using System.Collections.Generic;
using System.Linq;

namespace Linq
{
    class Program
    {
        static void Main(string[] args)
        {
            var listThree = new string[] { "Pete", "On", "Software" };
            var listFour = new string[] { "Joel", "On", "Software" };

            var stringExcept = listThree.Except(listFour);

            foreach (var s in stringExcept)
            {
                Console.WriteLine(s);
            }
        }
    }
}

The output of this code is

Pete

In this example, I used a string array instead of a generic List to show that other IEnumerables could be used. When calling the Except() method, I get the unique value(s) from the first IEnumerable. Intersect() would have returned

On
Software

and if I had written

var stringExcept = listFour.Except(listThree);

it would have returned

Joel

so much more care is needed when using Except() to ensure exactly which group has the unique values that you want to keep. However, there is one more thing you can do. What if you want to find every distinct value between the two lists? You would do something like the following

using System;
using System.Collections.Generic;
using System.Linq;

namespace Linq
{
    class Program
    {
        static void Main(string[] args)
        {
            var listThree = new string[] { "Pete", "Pete", "On", "Software" };
            var listFour = new string[] { "Joel", "On", "Software", "Software" };

            var uniqueStrings = listFour.Union(listThree);

            foreach (var s in uniqueStrings)
            {
                Console.WriteLine(s);
            }
        }
    }
}

which returns

Joel
On
Software
Pete

The above shows all of the unique values from the first group and any of the unique values that the second group brings to the party that the first group didn’t already have.

This is pretty powerful stuff if you have to process lists and should ensure that you are doing the most efficient operations possible. Linq is, of course, pretty exciting stuff and as I uncover more nuggets from the Pro LINQ: Language Integrated Query in C# 2008 book, I will share them here.

Code Tips

Lambdas – An Introduction

Lambda Lambda LambdaI will admit that I was pretty confused about Lambdas at first. There was a lot of hype about it and the syntax threw me at first. I wasn’t sure how to read (in English) what the code was trying to do. Some time ago, I decided to really bear down and figure out what this was about and I’ve decided to share what helped me so that maybe it could help someone else.

Lambdas were added with C# 3.0 (which shipped with the 3.5 Framework, which runs on the 2.0 Runtime… ah Marketing!). However, in reality, they are basically some syntactic sugar around anonymous delegates which have been around since the 2.0 Framework came out. Let’s look at this very simple code.

using System;
using System.Collections.Generic;

namespace Lambdas
{
    class Program
    {
        static void Main(string[] args)
        {
            List<object> list = new List<object>() { 1, "a", 2, "b" };

            List<object> justNumbers = list.FindAll(IsInt32);

            foreach (object i in justNumbers)
            {
                Console.WriteLine(i);
            }
        }

        static bool IsInt32(object input)
        {
            int i;
            return Int32.TryParse(input.ToString(), out i);
        }
    }
}

Okay, the Find() and FindAll() methods on the List<T> take a Predicate as an argument. What a predicate is is a special kind of delegate (a way to pass around a function or method like a variable) that evaluates a specific item and determines if it is true or false for some condition. In this case, I return whether or not the object is an integer. I have named my predicate IsInt32 and I pass it by name into the FindAll method.

I could also use an anonymous delegate and just declare the bit of code inside IsInt32 inline to that FindAll method. That looks like this.

using System;
using System.Collections.Generic;

namespace Lambdas
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<object>() { 1, "a", 2, "b" };

            var justNumbers = list.FindAll(
                delegate (object o) {int i; return Int32.TryParse(o.ToString(), out i);}) ;

            foreach (object num in justNumbers)
            {
                Console.WriteLine(num);
            }
        }
    }
}

In this case, I declare to the compiler that I am going to declare an inline method to use and that it is to be treated as a delegate (and as such can be passed around). If you compile and run both programs, you will see that they produce the same output. But none of this is a lambda. Lets take a look at the last example with lambda syntax.

using System;
using System.Collections.Generic;

namespace Lambdas
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<object>() { 1, "a", 2, "b" };

            var justNumbers = list.FindAll(
                (object o) => { int i; return Int32.TryParse(o.ToString(), out i); });

            foreach (object num in justNumbers)
            {
                Console.WriteLine(num);
            }
        }
    }
}

Okay, we only changed our syntax slightly. We ditched the delegate keyword and we put in this funny => symbol. What that has done is has identified an inline method a different way. In the snippet below we are defining that our method takes a parameter of type object named o and then the => means “this method then does” and then I go on to put code that would exist in that method.

(object o) => { int i; return Int32.TryParse(o.ToString(), out i); }

However, we can ignore the type definition, because the compiler can infer the type for us. So that code can then become

o => { int i; return Int32.TryParse(o.ToString(), out i); }

That doesn’t read any differently, but this syntax (the common syntax, btw) is what I’ve found confuses the most people. In fact, to prove that I’m not lying to you, I’ve built my project with that line in it (the o=>) and then looked at the code in Reflector. This is what is returned for the relevant section.

List<object> <>g__initLocal0 = new List<object>();
        <>g__initLocal0.Add(1);
        <>g__initLocal0.Add("a");
        <>g__initLocal0.Add(2);
        <>g__initLocal0.Add("b");
        List<object> justNumbers = <>g__initLocal0.FindAll(delegate (object o) {
            int i;
            return int.TryParse(o.ToString(), out i);
        });

As you can see, the compiler took that syntax and merely created an anonymous delegate just like in our anonymous delegate example. You see the delegate keyword is in there, as well as the explicit “object o” declaration.

I can also take a second to “nerd out” about Reflector and point out another bit of compiler trickery. You see that I had been using the “object initializer” syntax when I declared the initial List<object> where I filled the list just by including the items after the declaration inside of the curly braces. If you see the Reflector code, the compiler still has to generate the code that does list.Add(), even if I am spared the keystrokes.

Hopefully, this has been a helpful introductory primer on Lambdas for anyone who may have been having some confusion. Another time I will take a look as to how lambda expressions can be used in LINQ.

Code Tips

WCF Service Error

I was modifying a service last night and I got this error when I hit one of the two endpoints of the service.
The server was unable to process the request due to an internal error...
For search engines (and anyone having a hard time reading the image), it says:

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs

The other endpoint on my service was unaffected. Usually when I do something stupid, I get the “Yellow Screen of Death” the first time I try to reach my service due to an improper web.config or some other easily correctable thing. This was the first time that I had seen this.

I did some Googling and found out specifically how to get the “real” error message. I had to change my serviceDebug tag in my service’s web.config (located in system.ServiceModel/behaviors)

 <serviceBehaviors>
        <behavior name="PeteOnSoftware.SampleService_Behavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
</serviceBehaviors>

This gave me a much more helpful message telling me that one of the elements in one of my request objects had already been defined (name and type were the defining factors) in another existing request.

There were two fixes for this. Once was a “hack” in my opinion and the other was the “correct” solution. The hack was to turn off metadata exchange on that endpoint (my particular error was related to generating the WSDL). To do that, I would have set the

<serviceMetadata httpGetEnabled="true"/>

to

<serviceMetadata httpGetEnabled="false"/>

and remove this line from beside my endpoint definition.

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />

That would prevent developers from inside the company from generating proxy classes automatically with svcutil.exe. I didn’t want that at all.

What I did instead was to rename the element to something that made more sense anyway. This time when I built, the endpoint came up with no problem and the link to the WSDL returned the proper XML that developers would need to “reproxy”. Problem solved and lesson of the includeExceptionDetailInFaults learned!