Punit, is Microsoft MVP and, has over 8+ years of professional experience working on designing Enterprise Applications on Microsoft Technology Stack especially for Financial Sector. He is an open-source contributor of CodeInject, Workflow Extractor and dI.Hook on CodePlex, has 6 applications in MarketPlace, and a freeware application 'myTracker' on Softpedia. He writes on various topics on his website & has spoken in various forums in UK and Singapore and is blogs on his website www.ganshani.com and social blog site www.codetails.com Punit is a DZone MVB and is not an employee of DZone and has posted 20 posts at DZone. You can read more from them at their website. View Full User Profile

Developer Interviews – Code First Approach

08.28.2012
| 7143 views |
  • submit to reddit

One of challenges that I’ve seen people facing while executing projects is that they often end up having people in their team  (many a times screened by some experts) who are not good at writing quality code.  There could be many arguments that writing code is not the only thing when working in an IT organization, but I have closely observed and built my theory.

Most of the projects that we execute or applications that we build do not require us to write code from scratch.  Which means, either someone has already written some code (also means the design already exists) and we are extending the design specifications, or we just maintaining it only as much as it is required to keep our end-users happy.  Software evolves, it is not created!

I am sure some of the readers would be working on green-field projects and they would disagree to the above said.  I, myself, have worked on several green-field projects but these projects are very rare to find.  Most often, projects that are on the verge of retiring tend to produce green-field projects or projects that cater to a distinct set of requirements to be used for a specific purpose turn out to be green-field projects.  But this number is small. Or putting it in other words, the profit made from these projects is less.

Believe me, the skills required to design a green-field project are same as required to maintain a version of a “live” project.  That’s where the catch is.  Maintenance projects aren’t easier to develop.  Writing code within the boundaries of design created by someone is more complex than defining your own boundaries and writing code within them.  Oh, of course if we do not want the code to be maintainable, readable, scalable then we ought not worry about code quality in a maintenance project.

Software evolves, it is not created!  And this evolution requires developers to be able to write code while they perform other monitoring, reporting and rewarding tasks.  And even if you or your team members are engaged in any non-development tasks, being able to write code is the easiest way to hone your analytical skills.

So with this philosophy, I prefer candidates who may not necessarily perform the task of development on a regular basis but can write code if the need be.  Now, you don’t need to be code masters.  You need to be logic-crackers and the “CAN-DO”-attitude man.

When interviewing a candidate we usually check his communication skills and attitude, technical & analytical skills if he is required to write code, presentation, leadership and risk taking abilities for senior roles and …. (may be a HR can add more qualities screened).  But all roles need the candidate to be sound in logic.  So for testing logic, I prefer to give some very simple program to write in any language of their choice.  English is also one of the languages!  Believe me I see 40% rejections at this stage of interview.  Candidates with niche skills sometimes are not able to think through the solution.  May be it is the stress, or may be it is that they never expected a question that simple.  By asking someone to write code, you aren’t checking their development-quotient. You are instead checking if they will be able to apply logic in problems of smaller or larger scale.

Like say, a favourite question of mine is,

With simple mathematical equations, write a program that will swap two numbers

There are several solutions to this problem.  But when someone uses more than 2 variables, they leave you with no choice but to reject.  With 3 variables, even a 10-grade student would be able to swap 2 numbers.  What this problem statement refers to is applying the mathematics we learnt long ago.

Another simple program that I generally ask them to write is,

While iterating through 1 to 100, for every odd number print “Thumbs” and for even numbers print “Up”.  For a prime number, print “ThumbsUp”

One more,

If for every 3 steps that I take ahead, I take 1 step back.  When would I cross a point that is 100 steps ahead of me?

That’s again mathematics – no programming language knowledge required.   And if you are speaking to a candidate who knows a programming language, you better ask them to write a simple program of say factorial, or Fibonacci series.  We are not looking at perfect answers here.  We are looking at how they analyse a problem, their approach, their willingness to do something that they haven’t done since long.

When questioning on software design there are ample of questions available on the Internet and almost all candidates would have gone through them.  But a real time problem can be a googly to most brilliant minds.  Even I’ve faced a googly in a discussion I’ve had sometime ago.  Again, one of my favourite design puzzles is,

We are required to build a tic-tac-toe game for 2 players, X and O, who take turns marking the spaces in a 3×3 grid. The X player usually goes first. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game.

If you were to design this game (not develop), identify the classes that you would create?

Most of the candidates, here, misinterpret the question.  They start describing the interfaces and inheritance they would use; or would start with a Windows application and define UI elements like grid, buttons, etc. Everything is given as an answer, but the names of classes.

Problem statements could be many.  Puzzles could be endless. When you are hiring someone, get the man who could sit besides you and challenge your logic and quotient.  Not one that keeps appreciating your intelligence!

Published at DZone with permission of Punit Ganshani, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Rajat Agrawal replied on Wed, 2012/08/29 - 12:14pm

I think you should also give the solution to the question which you have raised in ur article. like TIC-TAC-TOE as people generally find the question but never reach towards the right answer.          

Craig LaValle replied on Wed, 2012/08/29 - 1:10pm

So....regarding the "swap two numbers" problem; why would you reject a candidate that jumps to the straight forward solution?  I'd personally want the person who does the expected rather than the person who tries to be too clever.

Jack Nicholson replied on Wed, 2012/08/29 - 4:57pm

I tend to disagree. If you want to see if she is a good programmer, give her a *real* mini project.

Give her an afternoon and ask a program that solves a real problem with more than one function to write.

First, a lot of programmers *hate* to program on a white board. A debugger with an IDE and google are perfectly acceptable tools because this is what you gonna work with !

Second, programming is more than just a pure mathematical algorithm intellectual masturbation, you overlook the structure of the code, the naming, the comments, the architecture, a smart usage of third party libraries, common sense, optimisation vs readability etc etc 

Third, I prefer to have an interative solution, that's how people work in reality. Not spotting the perfect solution at the first answer is *not* a problem as long as the individual continues to think and improves it.  This is because sometimes a quickly found, non-perfect solution is enough ! You can always come back to it if you need it so you can optimize your brain power on something useful.

 

Punit Ganshani replied on Thu, 2012/08/30 - 8:08am in response to: Jack Nicholson

I agree, giving time to someone write code over a day is a good practice but we often dont have the liberty to give so much time in the first stage of selection.

In regards to mathematics, yes I agree its more than that.  But you can train someone on coding standards, comments, readability, etc and knowledge about architecture is gained with time by reading and getting exposure to different styles.

The purpose here is to bring a point that some one logically sound may be able to catch up the other facets of programming and give you quicker results.

 

Punit Ganshani replied on Thu, 2012/08/30 - 8:10am in response to: Craig LaValle

Again, in my perspective, I am looking at "logic", "out-of-box thinking" and ability to "respond differently" to probably the simplest question at the spur of moment :-)  You could get different ways to solve a problem given lot of time may be even google it to see solution provided by others.

Jack Nicholson replied on Thu, 2012/08/30 - 8:58am in response to: Punit Ganshani

"But you can train someone on coding standards, comments, readability,"

I have a lot of counterexamples in teams I managed.

Usually the more the developer is thinking "out-of-the-box" the more you will have hacks and shortcuts everywhere in the code and the more you will have other team members pissed because yeah the code of this guy is just "out of the box", it doesn't follow any conventions or standard or common sense...

Don't get me wrong, it is important also to have a some team members with this ability but as a prime criteria to hire a developer it is way below having an excellent computer culture for example.

 I often ask questions like what is the difference between those 2 loops : 

for i in range(0, BIG_NUMBER):

    for j in range(0, BIG_NUMBER): 

         array[i][j]+=1

and 

for i in range(0, BIG_NUMBER):

    for j in range(0, BIG_NUMBER): 

         array[j][i]+=1

 

If you find the difference this is not "thinking out of the box", this is beeing a good computer scientist who knows what he is doing.

 

 

 

 

Punit Ganshani replied on Thu, 2012/08/30 - 9:03am in response to: Rajat Agrawal

@Rajat, mail me your solution & we can discuss different angles to it :-)

Lund Wolfe replied on Sun, 2012/09/02 - 12:51am

I, too, am not at all confident that you can train someone to write quality maintainable code that is readable with good comments.  This may be more of an art, craft, innate ability rather than a problem solving, logic skills type intelligence.  These skills may be even more important for new development, and even maintenance will require some low level design decisions.

Of course, OOD type questions are more relevant and should result in more maintainable code because it is correct, simpler, and easier to follow.  The code itself can be cleaned up and fixed later as needed.  The hardest part of maintainance is understanding the design so you can enhance or fix the code.  It would be less risky to make the questions more complex and give the applicant some time to get some real code to see their problem solving and design skills and their code.

New development and maintainance do require different skills and there is no reason to believe that someone who is good at and enjoys one can be switched to or trained to do the other.

Nick Maiorano replied on Sun, 2012/09/02 - 9:19am in response to: Craig LaValle

Punit,

 I'm troubled by your statement that you would reject a candidate who would opt for the most obvious and standard way of swapping two variables. Here are 3 ways to swap:

 //Way 1: classic way to swap 2 variables

temp = a;

a= b;

b = temp;

 

//Way 2: Clever for the sake of being clever

a = a + b;

b = a - b;

a = a - b;

 

//Way 3: The WTF way

a = a ^ b;

b = a ^ b; 

a = a ^ b; 

 

I would prefer the candidate who would choose option 1. Most developers can parse those 3 lines of code intuitively whereas most would have to pause and think about what's going on in the other two. You get bonus points for simplicity in my book.

Chris Treber replied on Tue, 2012/10/23 - 3:00pm in response to: Nick Maiorano

Amen. If anybody I interview came up with a solution other than option 1 and would give me the impression s/he is serious about the other ways being viable options, that would be a strong "don't you touch my code" signal.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.