Tuesday, November 29, 2011

How to interview well for a programmer position - Part 1

Our team is currently trying to add new programmers. We've been on the lookout primarily for seasoned programmers with good .NET skills, but we've recently broadened our search to entry level candidates simply because there seems to be more demand than qualified candidates these days. This is good news for those folks looking for work or looking to move up, but it makes interviewing candidates a potentially disheartening affair simply because candidates come unprepared.

If you are indeed serious about being a hire-able programmer, there are some things we look for, and these should be true no matter where you end up working. The first and most important quality we are looking for is that you are passionate about programming. What are you doing on a weekly basis to improve your skills? What new languages or technologies are you learning and exploring? What blogs do you read? What podcasts do you listen to? How many tech books have you read through this month? Are you involved in any programmer groups, local meetings, or code camps? Do you have a side projects you're working on? Are you ready to show off some sample code? Work on any code katas lately? If I ask you these questions and you come up with next to nothing, I am going to be tempted to ask you to leave the interview early. Anything I ask you after this may reveal your ability to do work, but it doesn't mean you're the kind of person who enjoys programming and actually wants to show up to work every day. If you're not doing any of these things, please start or find another line of work!

When it comes to the interview itself, be prepared to actually write some code! That seems fairly obvious, but I swear 90% of the candidates have a look of panic when I hand them an Expo marker and then ask them to sketch out a simple method. Remarkably, most candidates struggle with such a simple exercise which entails nothing more than what should already be second nature to you if you're a bona fide programmer. On one job interview I went on, the hiring manager sat me in front of a computer and asked me to program a simple web page for a blog comment entry system. He dictated the specs as I wrote it and was so impressed that I could actually do it that he was ready to hire me on the spot. Too often, I see people struggle with the simplest algorithm. Be ready to code "on your feet", and that just means more practice on your desired platform until Google is a last resort, not your first instinct. I highly recommend coding katas  as a practice tool.

Look, I'll even give you a freebie. I typically start with a simple problem such as "given a string that contains your first name, write a method that returns a string with the spelling reversed". Sounds easy, right? It is, but if you take all 30 minutes of our interview time to solve it, you won't be working with me. Something that trivial should take you 2 or 3 minutes, and you should probably be able to solve it in at least 2 different ways. (If you're a .NET programmer, you could use LINQ to do it in 2 lines.)

The same is true for databases. If your previous jobs involved writing SQL queries and stored procedures, you can better believe that I am going to ask you to write up a few simple queries to prove that you can actually do it without Googling. Be ready to know how to write a simple JOIN, and for gosh sakes know the difference between an inner join and an outer join.

The bottom line is that you need to be ready to prove to the hiring manager that you can do the job without a lot of help. The best way you can do that is practice your programming skills in your target platform so that when people ask for something easy, you don't hesitate and you simply do it.

Monday, November 14, 2011

To length or not to length - that is the question

I needed to find a way to determine if a Silverlight app had been loaded in a div of an iframe. I wasted some time  trying to set a boolean flag and tracking events trying to get it set correctly. jQuery to the rescue! The consensus seems to be that this is the best way to check for the existence of a tag:

if ( $('#targetdiv').length > 0 )

or if you want to be tricky

if ( $('#targetdiv').length )

Of course, my target div was in an iframe so I used this:


if ( $('#ResultsFrame').contents().find('#silverlightControlHost').length > 0 )

Tuesday, September 20, 2011

Traversing the Visual Tree in Silverlight

I recently had a problem where I had to find user controls within a ListBox. I was dismayed to find that there were no jQuery or LINQ style methods for traversing the visual tree in Silverlight! (Or at least I couldn't find anything.)


I discovered a workaround here.


In my case, I had to take it a step further, because I wanted all the controls that implemented a particular interface. I added one line of code and now it looks like this:


private void GetChildren(UIElement parent, Type targetType, ref List<UIElement> children)
{
    int count = VisualTreeHelper.GetChildrenCount(parent);
    if (count > 0)
    {
        for (int i = 0; i < count; i++)
        {
            UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
            // if the types match or the type implements the interface type
            if (child.GetType() == targetType ||
                child.GetType().GetInterfaces().Contains(targetType))
            {
                children.Add(child);
            }
            GetChildren(child, targetType, ref children);
        }
    }
}
In use it looks like this:

private void SetExpanderStateForCategoryControls(ExpanderState expanderState)
{
    bool isExpanded = false;
    if (expanderState == ExpanderState.Expanded)
        isExpanded = true;
    if (expanderState == ExpanderState.Collapsed)
        isExpanded = false;
 
    List<UIElement> categoryControls = new List<UIElement>();
    GetChildren(GeneralProfileSlotsListBox, typeof(ICategoryControl), ref categoryControls);
    GetChildren(BioProfileSlotsListBox, typeof(ICategoryControl), ref categoryControls);
    foreach (ICategoryControl categoryControl in categoryControls)
    {
        categoryControl.IsExpanded = isExpanded;
    }
}
EDIT: I managed to condense the use case quite a bit. I didn't need to loop thru the list box items to search for the controls I was looking for.

Wednesday, June 15, 2011

Debugger Canvas

Just found this through Reddit, and this is something such that if you're using Visual Studio 2010, you should take a moment and check it out. I can't believe I am so excited about a debugging tool, but this thing is effing brilliant.


"Debugger Canvas is a new user experience for the debugger in Visual Studio Ultimate. It pulls together the code you’re exploring onto a single pan-and-zoom display. As you hit breakpoints or step into code, Debugger Canvas shows just the methods that you’re debugging, with call lines and local variables, to help you see the bigger picture."

Be sure to watch the video, because the description doesn't do it justice.

A few months ago, I had to update a legacy app that seemed to defy our ability to follow the program flow. It took me an entire afternoon to whiteboard the various method calls. Had I had this tool then, I probably could have had it figured out in minutes instead of hours.

I will be the first to admit that I drink deeply from the Microsoft Kool-Aid well, but gosh darnit it's stuff like this that makes me happy to be a .NET programmer.


First Post!

I've been meaning to do this for years, and I'm finally making myself do it. I need a blog for coding, if anything just to remember sometimes the things that are important to me. If they help others, then great!

I'm a web developer who focuses on .NET technology, so most of this blog will about topics surrounding the .NET framework in some manner.