Coder or Clown?

Posted August 17, 2011 at 7:50 am by Ed Guiness

That’s the challenge.

Sit down with someone you’ve never met and try to work out if they are a coder or a clown.

I don’t mean to insult anyone, of course, and I’m the first to acknowledge the years of training and effort that goes into being a professional clown.

But some coders, oh boy.

Like the time I interviewed a recent graduate. I’ll call her Ada. Full of sympathy for the novice programmer I started with a gentle warm-up, a soft-ball question to break the ice.

I asked Ada to write some code, on paper, that would print the word “hello” ten times. Any programming language would be fine, I said.

Here’s what Ada wrote.

On the positive side there were no spelling mistakes.

This is where I risk upsetting some clowns masquerading as coders. I had expected some awareness of basic looping structures. Is that too much to ask, do you think?

No, I don’t either.

Some people collect stamps. I collect examples of dodgy code. I pick them up from code reviews, and I’ve been blessed with many years of good harvesting. I collect them mainly for fun, but they’re awfully handy for interviews too.

I might pick ten examples for an interview, most usually in C# and TSQL, and ask the candidate what they think of them.

Actually, I’ve done this often enough to develop a bit of a patter, something like this:

I’m going to show you some code. All these examples were found in real code reviews, and in every case the code was ready for release to real customers. You can assume that it compiles, has been tested, and works according to the spec. What I’m looking for are issues that would concern a maintenance programmer.

The Syntax Clown

So let’s say I pull out a code sample like this

if(long.TryParse(x, out number))
    number = long.Parse(x);

In case you’re wondering, I’m hoping coders will spot that the second line is wholly redundant. But the Syntax Clown will immediately point out the variables x and number haven’t been declared.

“Remember”, I say, “this is just an extract from a larger body of code, we know it compiles and has been tested.” Then I will pause, optimistically.

The Syntax Clown inevitably replies “but you haven’t declared the variables!

“Tell me the variables aren’t declared again, I dare you.
Tell me one more goddamn time.”

 

The Everything’s Rosie Clown

If the Syntax Clown is guilty of not listening, the Everything’s Rosie Clown is more guilty.

Rosie refuses to believe there’s anything wrong with the code, even after I’ve effectively said “here is some crap code, see if you can spot it!”  Clearly bad code does not exist in the magical fantasy world where Rosie lives.

“There’s no such thing as badly written code,
and besides that, just look at my lovely hair!”

 

The “I definitely know, but I just can’t explain it” Clown

With a firm tap on the paper and a sage nod of the head it is obvious this clown knows exactly what’s wrong with the code.

But right this minute they just can’t find the right words to explain it.

And they can’t find the words even if you give them a minute. Not even if you wait all day.

If you waited until the end of time their skeleton would be sitting and nodding wisely but still at a loss for words.

Despite their insight and instinctive trouble-shooting ability, these clowns just can’t get the words out. It’s a shame.

“Wait! I know this one!
Now, how can I dumb it down for them…”

 

Rube Goldberg Clown

This clown is fascinating. They will never write a simple loop when they can write an iterater. They will never simply iterate when they can recurse. If you wanted to scoop an obfuscation contest, these are the clowns for you.

“This code obviously lacks an abstract-proxy-façade.”

 

Angry Clown

Many times I’ve been greeted politely, had a pleasant conversation about the weather, made some tea and settled in for a good chat about programming.

Then all hell breaks loose.

Angry Clowns are cool, calm, and collected, right up to the point where you ask the first question.

“How the F**K should I know,
that’s a stupid F*****G question”

 

It’s not all that bad

To be fair, if someone interviewed me they might think I was a clown, maybe a few of these clowns mixed together. That’s the interviewer’s prerogative.

What’s more, some coders might think they’ve been interviewed by the Ringling Brothers. That’s their prerogative.

Whatever the outcome, dear programmer, know that I’ve tried to build a rapport. Sometimes it’s just hard.

Funny though.

 

@KiwiCoder

 

Entry filed under: Hiring, Interviewing. Tags: .

IT recruiters, in their own words

56 Comments

  • 1. slawek  |  August 19, 2011 at 9:22 am

    People might get nervous, but yeah… maikng mistakes being interviewed is unfortunate :P

    But… interview is a fun when you win, but when you loses it appears as a stinky waste of time

    Conclusion – chill out ;>

  • 2. T800  |  August 19, 2011 at 2:00 pm

    As short as It gets (VC6-style):

    for(int i=0; i<10; i++, printf("hello"));

    Do I qualify ;) ?

    • 3. mr foo  |  August 19, 2011 at 2:27 pm

      This is shorter (javascript, using global variable declaration

      for(i=10;i–;)alert(“Hello”)

    • 4. nod2fint  |  August 19, 2011 at 2:32 pm

      respect. you sir qualify as a clown! be proud of it..

    • 5. Tom  |  August 19, 2011 at 2:48 pm

      Yes! Your code qualifies for the bad code sample part of the interview!

    • 6. svella  |  August 19, 2011 at 11:50 pm

      It can be done shorter:
      for(int i=10;i–;cout<<"hello")

      and although the problem statement didn't explicitly call for it, usually you would want each hello on a separate line, which could be done in the same number of characters using puts() instead of cout<<.

      • 7. Laurent Lerusse  |  September 18, 2011 at 6:25 am

        Shorter does not means more maintainable.

  • 8. jkricka  |  August 19, 2011 at 2:15 pm

    Pulp fiction reference made my day!

  • 9. Ian R  |  August 19, 2011 at 2:29 pm

    Ada just optimised her code using loop unwinding (http://en.wikipedia.org/wiki/Loop_unwinding) !

    • 10. Matthew Graybosch  |  August 19, 2011 at 4:30 pm

      You’re not supposed to do that stuff yourself. That’s the compiler’s job.

  • 11. igguk  |  August 19, 2011 at 2:37 pm

    print “the word hello ten times”
    end

    Definitely not a Rube Goldberg clown ;-)

  • 12. Tim  |  August 19, 2011 at 2:40 pm

    Shorter than Ruby’s

    10.times { print “hello\n” }

    ?

  • 13. RK  |  August 19, 2011 at 2:56 pm

    Wouldn’t the code Ida gave work best? In a loop of printing the same thing over and over, wouldn’t you loose efficiency in the assembly jumps… a good compiler would just unroll this anyway, right?

    • 14. RK  |  August 19, 2011 at 2:57 pm

      “unroll this” meaning “Unroll a loop if that is how you coded it”

    • 15. RK  |  August 19, 2011 at 3:12 pm

      Loved the Pulp Fiction reference.

      …and the Angry Clown. Have one on my team… every time they don’t understand something either the “developer made it overcomplicated” or “it’s retarded that it has to be done that way.”

      • 16. PW  |  August 19, 2011 at 5:36 pm

        We have this clown for an interviewer and software manager.

  • 17. TedvG  |  August 19, 2011 at 3:01 pm

    Ah. Actually, what Ada did (what’s in a name)
    was cool..

    Ada’s program was:
    -completely bugfree!
    -very efficient! (no loops, loop vars, no stack etc,)
    -easy for the maintenance department!
    -perfectly readable!
    And then, you’ve asked for a hard coded FIXED (10) number of prints!

  • 18. Brandon  |  August 19, 2011 at 3:07 pm

    TSQL -

    PRINT ‘HELLO’
    GO 10

  • 19. Kurt  |  August 19, 2011 at 3:11 pm

    And in the end it doesn’t even matter, because you can’t even define what you want. Most managers are so removed from the programming process, they don’t even know what they’re talking about. I don’t know of a single manager that wouldn’t fail miserably under a microscope. That being said, I actually like your simple examples, but there’s a lot to keep in mind. In your example, it may not matter if an interviewer knows what that means. Most programmers do what they know and move on, so probably only know one of those ways to parse. Is that wrong?

    I know programmers that sound sophisticated, and it’s all crap, because their design will never work. The worst programmer I’ve ever seen had 2 masters degrees. The cockiest programmer that I’ve ever seen had 1 masters degree, and was always right, just ask him. Fed up with his mouth one day, I told him to put money where his mouth is. I tried to bet him a $100 that I could code twice as fast as he could, and my code would run faster. His best friend could come up with the task to code. He declined, and that was the last time I had to hear about all of his God like qualities.

    I think that you could probably skip the interviews , and hire based on the number of programming languages they have used. Be sure to include microprocessor programming.

    So who am I? The cleanup crew. Somebody has to have a good understanding…

    • 20. Paul  |  August 20, 2011 at 5:55 pm

      You can’t ever skip the interview. Many of the clowns I have seen are experts in C++, Java, .NET (according to their CVs). But they can’t show us how to sort a list of ten numbers, in any language like they like, using something really simple like a bubble sort.

  • 21. Really  |  August 19, 2011 at 3:36 pm

    I can’t believe you think recursion is for clowns.

    Tail Recursion is much more elegant than trying to write a loop. (For specific cases and not all).
    Are you educated? Do you understand the fundamentals of computer science and applied mathematics or did you learn to code from one of those 24 days books?

    • 22. e  |  August 19, 2011 at 10:11 pm

      actually, they said nothing negative against recursion… only that there is something wrong with forcing a shoehorn recursion solution in when a “simple loop would do” all likely in the attempt to save 15 clock cycles and 13.5 jump instructions.

      or just to see if they can. is this wrong? I don’t have an opinion one way or another, but from a software engineers point of view, you don’t want more than one or two of these guys in a team or you will never get anything code complete.

    • 23. Me  |  August 19, 2011 at 10:15 pm

      Recursion is slow.
      And more unnatural.
      You must wipe your ass as natural as can be, otherwise, too much recursion..

    • 24. Jake Jake  |  September 17, 2011 at 6:14 am

      You are sounding a bit like the angry clown!

  • 25. PR  |  August 19, 2011 at 3:39 pm

    @Tedvg perfect example of Everything’s Rosie Clown
    Most annoying type while interviewing, one of them was hell bent on convincing me that for upto 50 related variables there is no need to use arrays, as u can declare that many variables without getting tired.

  • 26. nickels  |  August 19, 2011 at 3:42 pm

    If you spent more time trying to suss out people’s strengths and figure out what they are excited and good at you would probably run into a lot more talent than you do giving people inane (banal) little toy problems that try to trip them up.
    Let me guess, you interview for google?

  • 27. LazyGuy  |  August 19, 2011 at 4:29 pm

    I’d be lazy enough to do this (Python 2):
    print “hello\n”*10,

  • 28. Shawn Mclean  |  August 19, 2011 at 4:33 pm

    There are actually coders like this out there and I bet many of them even get the job…and I cant get any… :( It sucks to be a programmer living in Jamaica.

  • 29. TedvG  |  August 19, 2011 at 5:28 pm

    @pr
    hihi. it was also meant as humor, you didn’t notice that? :o)
    I am having some fun. I’ve been programming since 1978
    in modern and classic programming languages
    In all these years I had to go through many often silly) but also constructive interviews.

  • 30. Paul Gehrman  |  August 19, 2011 at 5:28 pm

    The interviewers are usually the clowns, but of course, interviewing effectively is very difficult, so it’s easy to be a clown. I’ve always found that professional references always tell a much better story and I can usually get the information I need from references if I probe deeply enough. Asking someone to explain how to implement a singleton or explain polymorphism is a waste of time, as is asking them to code something. I think one of the best indicators of how good someone will be (especially at the senior dev level) is asking them more philosophical questions such as what they think of ORM. Their answer will speak volumes about how they view the inevitable tradeoffs that we make daily in our code. You’ll also be more likely to uncover an OO astronaut and save yourself the inevitable headaches that come from having to refactoring this person’s code.

    Finally, good pulp fiction reference. I’ll have to rememeber that the next time I’m in an interview.

  • 31. CoreAn_Crack3rZ  |  August 19, 2011 at 5:54 pm

    If I don’t pick on any of those clowns, whom will I hire???

    I guess most would be programmers will be a part of the clowns your describing. My question is who would be fit to be a “would be better programmer” if I hire one of those clowns.

  • 32. Jim de Graff  |  August 19, 2011 at 6:38 pm

    Shortest version in APL

    10 shape enclose ‘hello’

    but you have to replace ‘shape’ with the Greek letter rho and the word ‘enclose’ with the symbol that looks like the letter u rotated 90 degrees clockwise. That leaves you with an expression that is 11 characters long.

    Shortest version in Python is also 11 characters

    10*”hello ”

    but igguk’s version (print “the word hello ten times”) is my favourite response.

  • 33. sakamoto  |  August 19, 2011 at 6:55 pm

    Ok. I gotta disagree with you guys. Perhaps I am just being contrary :)


    ....
    const string hello = "hello"
    var numTimes = 10
    RepeatMessage(numTimes, hello);
    ....

    public void RepeatMessage(int numTimes, string text){
    for(int i = 0; i < numTimes; i++){
    Console.WriteLine(text);
    }
    }

    From a maintainability standpoint, that code is straightforward and encourages reuse. Separating the data from the method allows the method to move elsewhere, etc. I realize the example was trivial, but I would take the opportunity to demonstrate that I know how to write maintainable, extendable code that is not overly complex. Maybe, I'm all wet…

    –sakamoto

  • 34. Robert Stackhouse  |  August 19, 2011 at 7:40 pm

    You’ve got a typo on the line that begins, “Actually, I’ve done this often enough to develop a bit of a [pattern].”

    • 35. iji wonton  |  August 20, 2011 at 6:06 am

      Gay called. He wants his spell-checker back.

  • 36. Robert Stackhouse  |  August 19, 2011 at 7:55 pm

    I think this does a good job pointing out the dichotomy between what interviewers want and what academia is producing. People who can produce working tested software vs people that might be able how to tell you how it ought to be done.

    Knowing all the theory and buzzwords will only get you so far.

    I like the idea of testing the applicant’s ability to refactor code. I think adding a debugging test would be good as well.

    I agree with an earlier commenter that the ability to write code in multiple languages can be a good indicator of a good developer (for now). Interviewees have a tendency to game the system. This may or may not be related to the fact that all the postings I see for programmers start with, “Must have 5 years experience.” Not terribly sure I want to hire someone who took 5 years to figure out how to write an Asp.Net app.

    Thanks for making me laugh. The captions were great.

  • 37. Dan Sutton  |  August 19, 2011 at 7:57 pm

    Funny: when I interview programmers, I sort of know instantly if they’re going to be any good — has something to do with the way they carry themselves – the right mixture of arrogance and superiority complex — the really good ones recognize each other instantly, the way vampires are supposed to do…

  • 38. M-Auwal Gene III  |  August 19, 2011 at 9:58 pm

    Dan Sutton, that is so very aptly said: “I sort of know instantly if they’re going to be any good — has something to do with the way they carry themselves – the right mixture of arrogance and superiority complex — the really good ones recognize each other instantly, the way vampires are supposed to do…”

  • 39. Who Are You Calling A Clown? - FredSmullin.com  |  August 19, 2011 at 10:51 pm

    [...] ran across this post via the Code Project feed.  If you want to stir up debate, define your personal criteria as to [...]

  • 40. J B  |  August 20, 2011 at 12:22 am

    Great test but as an employer myself the most you want from an employee is honesty, and after that adaptability. Where in your silly tests do you ask for that? Your “print Hello ten times” test is meaningless. It is a question that no one would ever have done or use, so Ada may have thought what is this person after, probably a bit nervous, so answered it how she thought you may want it. For you to make the conclusion that that Ada doesn’t understand looping is in itself loopy. Lastly have you done any statistical modelling yourself? I would warrant that you have never employed an “Ada” (ie someone you did NOT like in the interview) to test whether your employment theory works. There is no statistical reasoning behind your theory. Who is the clown? Have a look at yourself.

    • 41. Bob  |  August 23, 2011 at 10:38 am

      I’m guessing you fall into the clown category – usually one finds that people who know their stuff don’t mind having to prove it. If you can’t prove it, you ain’t worth your paycheck. :-)

      • 42. J B  |  August 29, 2011 at 1:55 am

        I agree to allow people to show their worth is good, but does setting a silly test prove anything? Einstein failed to get into Zurich University at his first attempt. He couldn’t prove he was the world’s greatest physicist in a test and that presumably contained sensible questions. Einstein proved, among other things, that tests have very limited reliability.

  • 43. Harley Pebley  |  August 20, 2011 at 12:35 am

    Being a “Rube Goldberg clown” myself, and inspired by Tim’s and sakamoto’s comments, how about (C#):

    10.Repeat(() => Console.WriteLine(“Hello”));

    where:
    public static class IntExtensions
    {
    public static int Repeat(this int count, Action repeatAction)
    {
    Enumerable.Range(1, count).ToList().ForEach(n => repeatAction());

    return count;
    }
    }

  • 44. cagdas  |  August 20, 2011 at 8:54 am

    I have not met a rosie yet and nothing as ridiculous as the loop retard but I’ve definitely seen the others. I think the most dangerous is the rube goldbergs. And the ones that pass the interview and do not write any code because “there is always something wrong: requirements are not defined, the API is lacking a feature, etc”

  • 45. Pwistu  |  August 20, 2011 at 9:51 am

    everything should be made as simple as possible..but not simpler. – Einstein

  • 46. Всем сотрудникам отдела! «  |  August 22, 2011 at 10:39 am

    [...] 4. Кодер или клоун? [...]

  • 47. lonepsycho  |  August 22, 2011 at 12:33 pm

    clowns or not clowns… clowns do earn some extra cash for circus, or don’t they?

  • 48. Another Voice  |  August 22, 2011 at 1:10 pm

    C# guys != coders

  • 49. Someone in nowhere  |  August 22, 2011 at 4:34 pm

    DoIt();

    And let’s just say that it’s a method call for printing out “hello” x10.

    By the way, there are 2 other clowns:
    1) The “EnglishIsGreatSoUseItOverallClown”:
    He would write something like:
    int thisIsMyVeryGoodCounterVariableWhichIsGoingToBeUsedInTheExample = 0;
    int thisIsTheMaximumCounterVariableWhichIsGoingToBeUsedInTheExampleToo = 10)
    string thisIsMyVeryFantasticStringVariableWhichFinallyPrintsOutTheWord_Hello_WeAreLookingFor

    for( thisIsMyVeryGoodCounterVariableWhichIsGoingToBeUsedInTheExample < thisIsTheMaximumCounterVariableWhichIsGoingToBeUsedInTheExampleToo; thisIsMyVeryGoodCounterVariableWhichIsGoingToBeUsedInTheExample++ )
    {
    Console.WriteLine("thisIsMyVeryFantasticStringVariableWhichFinallyPrintsOutTheWord_Hello_WeAreLookingFor");
    }

    2) The 488rs Rul3Z clown:
    If he had to write a mathematical code, it would look like this:

    private int yyZZyzYYzZZyYzYCalcAddMdfrZyZ()
    {
    int yyZ = 582, ZyZ = 998, YYz = 3, ZZy = 15, YzY = 80;

    int YYY = yyZ(ZZy-YzY)+YYz*ZZy*YzY/-((-(-(ZyZ(ZyZ-ZZy)yyZ)-yyZ)yyZ)ZyZ)

    return ZZy*YYY
    }

    So noone in the world would understand what the hell this method does…even the clown wouldn't know 2 minutes after finishing the code.

  • 50. Rosie the Riveter  |  August 23, 2011 at 1:06 pm

    Is it fully redundant? If I had walked in cold and didn’t know what any of the variable were or what you were trying to accomplish with this code, and not having someone tell me there is a serious problem, I would suspect that the “tryParse” attempted to perform the parsing action but didn’t fail in the event that parsing was not viable, and if it didn’t fail, THEN it performed the actual parse. That type of test is not really that uncommon. If it were COMPLETELY redundant, it would say “tryParse” again. So I guess that makes me the “Rosie” coder. It would be interesting to know what percentage of the people you asked had my view of this code. You left out the people who think they are smarter than everyone else, and them makes up names for them.

  • 51. Rosie the Riveter  |  August 23, 2011 at 1:18 pm

    Ok – I wrote my prior comment before I drank enough coffee. What I was trying to say got confused. Here is what I was trying to say;

    (from msdn)
    The TryParse method is like the Parse method, except the TryParse method does not throw an exception if the conversion fails. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.

    So it did parse with the tryParse, and it is redundant, but without access to documentation, it’s not too far fetched to wonder if it might not have actually parsed, and someone questioning it should not be dismissed as a clown. (in my humble opinion).

  • 52. 【资讯】2011程序员?还是小丑? | 天天生活  |  August 29, 2011 at 2:46 am

    [...] Coder or Clown? [...]

  • 53. 程序员?还是小丑? | 麻菜.co  |  August 29, 2011 at 5:00 pm

    [...] Coder or Clown? [...]

  • [...] Coder or Clown? [...]

  • [...] Coder or Clown? 这篇文章翻译而来。 编译/外刊IT评论 赶快分享到: Facebook Twitter Delicious [...]

  • 56. Programmers? Or a clown? - Open News  |  November 7, 2011 at 12:49 am

    [...] article is from the Coder or Clown? this article [...]


ABOUT.ME

Ed Guiness

I am the author of Ace the Programming Interview, published 2013 by John Wiley and Sons. In 2012 I founded SocialCoder.org, a volunteering organisation for programmers. I've been a professional programmer for more than 20 years, and a hiring manager since 2004. Ask me anything.

Recent Posts