.NET and me Coding dreams since 1998!

20Jan/101

Do you want to learn DDD in 10 minutes? :)

· I’ve been doing a lot of presentations in last couple of years and people attending them know how hard was to fit most of them to 2 - 3 hour time slot (big subjects – trying to get into details)

So, when Andrew asked me if I would like to be one of presenters and pitch some subject in 10 (ten) minutes max I accepted immediately because sounds so challenging (read: fun).

So, my subject I would be presenting is “Quick introduction to Domain Driven Design” which in case you are newbie won’t definitely “teach you DDD” but (I hope) would be of some help getting a grip on some key concepts which understanding I find VERY helpful while reading “the blue book”.

I’ll also give my best also to present it in a way which won’t bore you to dead so it should be fun experience even you are “not newbie”.

In case you want to find out more details about the conference and register for 2 hours of pure information injection, click here.

Filed under: Uncategorized 1 Comment
8Jan/1014

Asking the right questions while interviewing developers

Just another fizzbuzz interview question

I really hate interviews regardless on which side of the table I am sitting during them(Ok, it is a bit easier when you interview candidates :) )

One of the main reasons why I hate them is the stupidity of the programming trivia and questions being usually asked: all sorts of binary tree related traversals, converting numbers from one base to another, number sequences  etc… I mean, who really cares about that stuff in everyday's work?? Am I applying for mathematician job or for a developer one?
I have a feeling those questions are created to fresh grads because they don’t have much real world experiences but that’s just me guessing..,

But, not all of the interview questions are stupid and the most famous example of what I find to be a good type of interview question is famous “fizzbuzz problem” described by Jeff Atwood and Scott Hanselman which is an example of very simple task which resolution is purely related on persons real-world like thinking skills and not related at all to any other type of knowledge.

Couple of years ago I’ve stumbled on a video recording of a session made by Brad Adams regarding his excellent Framework Design Guidelines book where he mentioned an example which looked so trivial to me that I quickly discarded it as very obvious to literally everyone. (I couldn’t find that link for this blog post :()

Couple of months after that I was interviewing a candidate for one senior position and due to the fact he gave fuzzy answers making me wondering if he gets heap and stack so I took Brad’s example idea and came out with a simple question looking something like this

namespace InterviewTrivia
{    
	public class ClassA    
	{        
		public override string ToString()        
		{            
			return "Hello from class A";        
		}    
	}    
	
	public class ClassB : ClassA    
	{        
		public override string ToString()        
		{            
			return "Hello from class B";        
		}    
	}    
	
	public class ClassC : ClassB    
	{        
		public override string ToString()        
		{            
			return "Hello from class C";        
		}    
	}
}

Nothing fancy here just 3 classes inheriting from each other and each one overriding object ToString() method

Now the console application Program class can be done something like this:

using System;
namespace InterviewTrivia
{
	class Program
	{        
		static void Main(string[] args)        
		{            
			ClassA first = new ClassC();                        
			ClassC second = new ClassC();            
			ClassB third = (ClassB)second;            
			ClassA fourth = (ClassA)third;            
			object fifth = (object)fourth;            
			
			Console.WriteLine("1: " + first.ToString());            
			Console.WriteLine("2: " + second.ToString());            
			Console.WriteLine("3: " + third.ToString());            
			Console.WriteLine("4: " + fourth.ToString());            
			Console.WriteLine("5: " + fifth.ToString());            
			Console.ReadLine();        
		}    
	}
}

As you can see there, first 5 lines are doing different variants of casting class c instance and then printing out the result of ToString() method.

I wrote this sample on a whiteboard (to avoid having R# helping him with the answer) and ask the candidate what would be the resulting output of an app.

Why is this fizzbuzz question?

Because it is:

  • very simple problem and code sample
  • focused on concrete programming scenario pinpointing the (IMHO) important OOP concepts which need to be understood by senior developers
  • in order to solve it one doesn’t need any knowledge other then programming skills.
  • it is white board friendly – very important attribute for DEV interviews

So, what happened?

To my surprise that candidate bluntly failed the test reporting as a result:

  1. “Hello from ClassA”
  2. “Hello from ClassC”
  3. “Hello from ClassB”
  4. “Hello from ClassA”
  5. “InterviewTrivia.ClassA”

I was done with the interview convinced this candidate was exceptionally bad and I’ve stayed convinced in that until accidentally I’ve run the same sample with couple of other developers and in most cases got the same answer as the candidate gave. That fact is maybe just the result that we .NET developers are really spoiled and allowed to be blissfully ignorant about how stack and heap in .NET works (which is btw the thing I strongly disagree), but that is not the point of this blog post.

The point is that with properly chosen trivia and programming questions we are using in interviews we can avoid loosing good candidates just because they don’t know for sure how to convert –1234.56 to hexadecimal base number (even on paper) and focus on getting information on really important attributes a new member of the team would be bringing to the team (or not) once joining the company.

(Sample code of today’s post can be found here)

Technorati Tags: ,,

Share this post :

Filed under: Uncategorized 14 Comments