Apps

Hiring a programmer? Ask these questions in the interview

Routine interviews for programmers often offer tests that evaluate rote memorization that the modern development environment doesn't require. Here are some better questions to ask.

One of the hardest things to do when hiring a software developer is to establish his or her level of expertise. It's pretty easy to learn what their attitude is like after a bit of time in an interview. But actual programming experience is tough. Some companies rely on various tests, but in my experience, those tests often evaluate rote memorization that the modern development environment does not require (e.g., between the IDE's autocomplete, F1, and the Internet, library knowledge is not as important as it used to be). Here are some questions that are good to ask a developer, and why they are good questions. If you don't feel comfortable judging the answers on some of the more technical questions, have one of your senior developers sit in as well. These questions are designed to be generic and allow you to "pre-screen" a candidate before you get to questions specific to your projects.

CS 101 questions

I had assumed for a long time that everyone billing themselves as a "programmer" had a certain baseline level of knowledge. I discovered that this was not the case at all! While not every developer has a degree in computer science, it should be expected that every developer understands certain fundamental ideas. While the ideas may not always come up in day-to-day programming, they are important for developers to understand. Some of these questions I like to ask are:

  • Explain the difference between "equality" and "equivalence" (credits to TechRepublic member Tony Patton for this question).
  • What is the difference between "pass by value" and "pass by reference"? How are these ideas different in object-oriented systems and procedural systems?
  • Describe "polymorphism."
  • Compare and contrast "pessimistic locking" and "optimistic locking."

Any candidate who cannot successfully answer the first two is "entry level" at best. The second two should be answerable for any "intermediate" developer.

Thought process

Much has been made of some companies like Microsoft and Google and the intense tests they use to evaluate how candidates approach problem solving. While those tests are well and good, the fact is that few managers and companies have the time to spend a full day interviewing job candidates and having them play puzzle games. All the same, it's important to get an idea of how well someone can think about a problem and communicate the solution. In my experience, the best example of this kind of question is "The Chicken Question." I first encountered it on a job interview about three years ago, and I thought it was an excellent question. You ask the candidate, "if you had your way, how would you design a chicken, and why?" There really are no "right" or "wrong" answers here, but a candidate who knows how to approach a problem well will be able to give a detailed answer. Some candidates will like to play "philosopher" (or worse, "heckler") and ask questions like, "Are we sure that we need to design a chicken in the first place?" These kinds of answers can give important insight into their work attitude as well. This question is a good one for candidates looking at senior developer or software architect positions. Of course, it doesn't have to be a chicken, either. It could be any kind of animal, a piece of machinery, etc.

Whiteboard programming

Something that has become less common in interviews (as far as I can tell) is "whiteboard programming," where the candidate is given a problem to solve and asked to use pseudo-code on a whiteboard to write an application to solve the problem, explaining along the way why they are doing what they are doing. In some regards, this is a more hands-on version of "the chicken question" and shows what the person would be like as a developer. You can use a variety of different scenarios for this, maybe something applicable to your environment or perhaps something more generic. The keys to a successful question here is to make sure that it can easily be expressed in a whiteboard's worth of pseudo-code and does not involve too much library knowledge. After all, you're looking for someone to demonstrate how he thinks about programming, not how well he functions without any tools! Some examples that might be appropriate whiteboard problems:

  • Calculate the Fibonacci value for a number X
  • Determine whether or not a given number X is prime
  • Reverse an array without using a loop
  • FizzBuzz

Yes, these are fairly basic questions, but you would be shocked at how few developers can give a decent, short piece of pseudo-code that handles them! Feel free to pull an example from the realm that your specific position hires from, of course.

One interview I went to had a unique twist on whiteboard programming: Instead of explaining the problem to me and having me write the pseudo-code, they wrote pseudo-code and asked me to explain what it actually accomplished. This is an excellent tool and makes a good test for someone's ability to delve into code and start troubleshooting or making changes.

Code reviews

Code reviews are a common part of the development process. Something that I've seen in interviews that can be effective is to show the candidate a piece of code and have her review it. Of course, the code should not be perfect, but at the same time, the flaws should not be the kind of things that a compiler will pick up like a missing period. Instead, you should be looking for a candidate who can make optimizations, find "fence posting errors" (and other common mistakes), and so on. This will show that that person understands the difference between good code and poor code and know how to write good code.

"The usual suspects"

In most interviews, there are a few standard questions that get asked. Things like, "What is the hardest challenge you have faced in your current position?" and "What do you consider your biggest weakness?" These questions are fairly worn out, but they do serve a purpose all the same. It's helpful if you focus the question on development. For example, instead of asking, "What's your biggest weakness?" try asking, "What aspect of Web development do you feel weakest in?" (or whatever kind of development your project is in). If your candidate lacks the exact set of skills that you're looking for, don't ask them, "Do you think you could come up to speed quickly in these tools?" Because, of course, she will say she can. Instead, ask for examples of how she has been able to perform jobs despite lacking the skill set at the beginning.

Closely examine the experience

One of the biggest problems when evaluating resumes is that candidates sometimes turn even the slightest association with a project into a central role. For example, the person who acted as a scribe in one brainstorming session might list "extensive specification development experience" on his resume. You really need to ask specifics about the past experience, particularly anything that interested you in the resume. Drill down into the answers. The following dialogue between Susan (the interviewer) and Kevin (the candidate) should give you an idea of how this goes:

Susan: On your resume, it says that you were key in developing a new CRM system. Tell me a bit about that. Kevin: It was a Web application written in ASP.NET with C# and Microsoft SQL Server. Susan: What was your role in that? Kevin: I focused on the data access layers and business logic and worked with a designer to tie it to the UI. Susan: What technologies did you use to communicate with the database, and where was the business logic stored? Kevin: Our DBA set up the initial table structure, and I used NHibernate to work with the database. From there, I created custom data access objects that exposed only the appropriate methods and functions, and I performed some additional data validation and transformations that were not appropriate to do in NHibernate or in the database itself.

As you can see, Susan was able to get to the heart of the matter very quickly. If Kevin had not been able to clearly define his role in the project, the technologies used, their limitations, and so on, it would have been a sign that Kevin's resume overstated his expertise.

Conclusion

Hiring a developer is not easy. And when you hire the wrong person, it can take a while to find out that that person has been making a mess of things, and sometimes even longer to reverse the damage. In an ideal world, we could use a lot more time than the typical interview to get to know the candidate, but we rarely have that luxury. These tips should get you on the right track to separating the poor developers from the good ones.

About

Justin James is the Lead Architect for Conigent.

81 comments
youareyouyou
youareyouyou

It's funny. I think the more 'abstract' interview tactics as proposed in this article (asking conceptual questions) are just emulated and copied from clueless dickhead managers from years past. While a few of these questions could be important to gauge the candidate's overall understanding of the SUBJECT of computer science... tech companies hiring programmers, specially start ups, need people who can build shit out of the box. I don't care about thesis' or analogies or most of these questions, I care that I can ship my product on time. If I have a bunch of brainy blowhards who can answer all these questions but suck at writing code my business will fail. Here's what we've been doing. We must have read every interview suggestion article on the Web. We take a hybrid approach. We ask a few conceptual questions. Then, we ask some problem solving questions, and JOIN the candidate to help him work through it when struggling. This simulates working in a real environment: can we work with this guy? Finally, the practical. Code something. Just do it. Show us what you can do. We'll make the decision pretty much right away whether we want to hire or not.

aaronaranya
aaronaranya

While you're CS 101 Questions are a great idea, I think questions like "Compare and contrast 'pessimistic locking' and 'optimistic locking.'" are less than ideal. I have been developing for over a decade and didn't know these terms. However, once I looked it up on Google I quickly understood what they were. I knew the concept, not what they were called. How about instead the question: "Explain what you know about database locking techniques and their advantages and disadvantages." This is very open ended and focuses not on the terms (who cares if you know what it is called?) but instead on the concepts (can you really do something with it?). As for the "Thought Process", we give our candidates real world situations we have been through. We present what we were given and say, "What would you to do troubleshoot and solve this problem?" It is actually rare to get a final solution as the problems we present took us weeks to resolve but it extracts out how a person troubleshoots problems that are out of the norm but really did happen. You can also combine your "White Board Programming" and "Code Reviews" by giving a chunk of code and say "Explain what this does and what you would do to fix or improve it." Then give some code that has a bug, memory leak or performance flaw. This is a good article. Thanks for the ideas. If you are interested in what we ask programmers right out of school (most have no clue what these concepts are), check out my blog at http://codeelixir.com - article "The 5 Most Important Things Programmers Should Know (but never learn in school)" . Also, we love it when a candidate comes in and tells us they read our Blog and is ready for the interview. I like to sprinkle little bits of insight about who we are and what we do on our web site and Blogs. A candidate that doesn't take the time to check our web site at least for a few minutes is unlikely to get the job because is shows lack of interest and inability to properly prepare.

srini_soma
srini_soma

I often give this code to answer, believe me 90% of candidates failed... int a=10; int b=20; { b++; int c=a+b; } printf a, b, c; (You can change the code to your language - C++/ Java) Most of the ppl responded saying result is 10,21,31. Are you also thinking same way :D ... ... It should actually give compilation error

mikifinaz1
mikifinaz1

Most of this "blog" focuses on the wrong aspects of the role of programmer. The "soft" side of working on a team is much more important than the programming skills. Programmers are a dime a dozen. Good programmers that can work effectively with other people is another matter. I don't know how many teams I have worked on that have been hobbled by programmers with raging egos or other major personality flaws that made it almost impossible to do the work.

rwparks.it
rwparks.it

I like your conclusion Justin. Still, what's the goal -- to find programmers who write code to meet stated needs, and ability to work in your group. Note: A test doesn't just tell if one knows right or wrong answers (i.e. regurgitate information). A test can also reveal the type person and his/her gifts and style. Seek to learn from the candidate: * Knowledge Level -- Questions above reveal the candidates exposure to programming constructs (particularly to OOP) and the candidate's grasp to the level you desire. Questions can reveal approaches as well knowledge. * Problem Resolution -- I don't know Fibonacci, but still grasped the concept after looking it up. * Problem solving -- A real programmer must be able to think, not just paste code together like a Lego set. The better chicken: Not all software shops need to reinvent the egg, they just need to get the job done. Others, though, need creative people to think outside the box and make advanced concepts real. Whiteboard programming: * Reveals a person's though process and presentation style to portray solutions. Code Reviews: * Documentation and Coding Style -- very important to know how the programmer's work will reflect in your company. "The usual suspects" and Closely Examine the experience: * Good to have the questions focused towards your need. Answers might determine how their ability to address that need. In fact, I think the article draws out the goal to know the candidates skills and their abilities to meet your needs. p.s. not mentioned, the interview process should determine a very important aspect for any role in IT -- Communication.

noogrub
noogrub

Gee, whiz, thanks for reinforcing a whole series of stupid interview philosophies. Far better than "How would you design a chicken?" is "Explain in detail one of your _recent_ design projects." and follow it with genuine inquiry: Why did you decide to use that data structure? How did you implement (insert your special interest here)? What do you wish you had done differently? If you know anything about programming, the resulting discourse will give good insights into the programmer you are interviewing. A chicken. Good grief. Folks, if you go to an interview and some Gomer asks you to design a chicken, get the hell out of there. The people you are considering working for are not competent.

prashant.goyal
prashant.goyal

So how do you reverse an array without using a loop?

Osiyo53
Osiyo53

Had to look up Fibonacci. Have heard the term, even VAGUELY remember studying Fibonacci numbers wayyyyy back when. I even use the mathematical methodology in real life from time to time, but had forgotten that this term applied to it. FizzBuzz I've never heard of, I'd have had to ask what the heck that was all about. Looked it up, once I knew what that term was all about it would've been simple enough to code a solution, in pseudo-code. In real code? Depends on what programming language you wished me to use. As concerns the chicken question, you could expect to get a lot of questions from me. Asking you specifics about what goals you expected this chicken to achieve or fulfill. After all, my concept of what might constitute a perfect chicken are likely different from your ideas. This last matter is crucial, and comes up virtually every working day of my life. In my working world, we write custom applications for customers all the time. Its what we do for a living, what we're paid to do. We sit down with a customer and go over their goals and expectations, and seek out any specific requirements they may have in mind. Everything discussed is noted, and later formalized into a project "specification". Each point and item is discussed and clarification sought. The point is, for our kind of work, custom programming under contract, it is not enough that the application just works and satisfies us ... the customer needs to to perceive that it works to their satisfaction in a way that suits their expectations and needs. i.e. In the past we've had customers complain (and feel dissatisfied with the end product) over issues like "look and feel". Or user interface too complicated or ambiguous ... requiring too many keystrokes or mouse moves, not intuitive enough to the average USER, etc. Or entries are not made in a way already familiar to the end user. Or the application requires specific hardware (such as video capabilities) that aren't part of every machine the app is expected to run on. Info isn't presented in a style of presentation the end users are familiar with and find easy to scan, read, understand. Etc ... endlessly on. My point is, in the past we've made perfectly good software, that performed technically perfectly a certain task or set of tasks. But which did not leave the customer with a good taste in their mouths. Not good if you're doing custom programming and hoping to do future work for the same people. Or hope to have them recommend you to their associates. Of course, when we're going through all this stuff and defining project specifications, here and there we DO offer suggestions, point out possible problems with the customer's ideas. Offer possible improvements, and explain why, which the customer can consider. But in the end, the app must not only work, it must work in such a way as to suit the customer's wants and needs. In short, it must not be simply a chicken, but the kind of chicken that would make the customer think it's the best chicken to be had, in THEIR opinion. Just some thoughts. BTW ... we do get them to sign off on those specifications. Just in case. We're produce EXACTLY the kind of chicken they defined. And in the end if they're not happy, we're gonna charge to make changes. Most times. In the real world we do have repeat customers with whom we've had a long standing business relationship, and from whom we've made significant money over time, who we toss a "freebie" from time to time. (Add a feature or modify something for free)

Mr_Tech
Mr_Tech

What is the difference between pass by value and pass by reference?? How are these ideas different in object-oriented systems and procedural systems? Passing by value is making a copy of the object and the original object isn't modified in anyway. It is like making a copy of a book, CD, software etc...while passing by reference is passing the address of the object stored in memory and any changes made to the object will effect the original object. You can either pass an object by reference by using a constant pointer (a reference variable) or a real pointer which you can use later on to store a different address. Describe polymorphism Polymorphism refers to a function with multiple forms. Each function can have a different signature/parameters it is taking. E.g: int test(), int test(int, int) will both compile and the right function will be called when called. The returned type isn't part of the signature. The other two don't know :) Can I still have the job and be trained?

srlevine1
srlevine1

The first question I ask any programmer is: "What experience do you have in my industry?" That sets the tone for an examination of their expertise. If I have a problem solver, language is almost secondary. Good programming and documentation skills can be determined from code samples. Trick "computer science" questions mean didly squat when solving real world problems.

jkameleon
jkameleon

I'll google for answers to these questions before my next interview.

Slayer_
Slayer_

* Explain the difference between ?equality? and ?equivalence? (credits to TechRepublic member Tony Patton for this question). Too ambiguous of a question. Especially on a language, do they mean how 1 "1". Because in VBA 1 = "1" but 1 cdbl("1"). Where as, & and + are equivalent operators with strings, but not with numbers. At what level are you asking this question? * What is the difference between ?pass by value? and ?pass by reference?? How are these ideas different in object oriented systems and procedural systems? It does not matter of its OO or procedural. Pass by reference means your passing a memory reference, pass by value means your passing a copy of the memory. * Describe ?polymorphism.? See Inheritance, also See over bloated code. * Compare and contrast ?pessimistic locking? and ?optimistic locking.? To a data base, or to a flat file, or to a network? # Calculate the Fibonacci value for a number X Whats a fibonacci? # Determine whether or not a given number X is prime Is it divisible by 2, 3, 5, 7 (i think those are the numbers...) # Reverse an array without using a loop Is this even possible? -Edit Looked up what a fibonacci was. Sounds useless unless your doing video game engine programming.

Tony Hopkinson
Tony Hopkinson

Personally, given my experience of academia, my number 1 would be writing readable code. Design Patterns is something I've become very very wary of. Far too often it's learn the patterns by rote and then use them in some sort of shake and bake strategy. Architectural cookie cutting as it were. As well as learning the basic patterns, as least as much emphasis should be on recognition. If you look at your list and my addition of readable code, and our discipline in he business world, there's an over-arching concept all the way through them, and it's this that's missing from academia. Change is a given. Today's question isn't yesterday's, or tomorrows. It has changed, it will change. Anything that makes change harder to manage or implement is bad. There is a similar lack in the business based approach to software design as well. It's subtle but Change Management and Change Control are not the same thing. One copes by enabling, the other generally by denying.

Tony Hopkinson
Tony Hopkinson

general direction. In any language where you can scope a local variable like this, there will be a compilation error. This is basically a coding typo, irrelevant drivel. Like judging my ability to interact on here because I sometimes spell type teh instead of the. The intent of teh ( :p ) code is obvious. If you want to look for people who can and can't. Look for the ability to unambiguously express intent in the chosen language.

jkameleon
jkameleon

In the olden days, there were two roles: system analyst, and programmer. System analyst collect requirements, and write specifications for programmer. Nowadays, programming is no longer a big deal, since modern IDEs do most of the programming gruntwork. Todays programming languages are also immensely more productive and intuitive than assemblers and languages of old, and no longer require special knowledge (*). This is the reason why the roles of system analysts and programmer are usually combined. What you call a "good programmer" is acutally a system analyst, who writes programs instead of specs. ____________________________ (*) Believe you me, programming a machine with a drum or mercury memory instead of RAM was quite a feat. Programming microprocessors in the 1980 was no trivial matter either, because there were no tools available back then.

Justin James
Justin James

... because it says to drill down into their experience and ask pointed questions. J.Ja

jkameleon
jkameleon

that competent people one could work for are so bloody few and far between. Before dotcom boom, people from the trenches were usually gradually promoted into management. Hiring and evaluating programmers was not a problem. During dotcom boom, speculative capital invaded the field. Investors, which didn't have a clue what they are investing into, hired equally clueless managers, whose sole mission was to commoditize everything, and make as much profit as possible, short term wise. Naturally, they fucked everything up in the long term on this account, in more ways than one. Clueless hiring practices is just one of them.

rwparks.it
rwparks.it

Another approach (in assembly) would use a stack. Push values on the stack. Pop values off the stack and assign in reverse order.

jkameleon
jkameleon

... but, in all honesty, why bother? It's just a useless waste of brain cycles.

Tony Hopkinson
Tony Hopkinson

I'd put domain knowledge, vs technical about 50 / 50.

jkameleon
jkameleon

Unfortunately, most of the industry considers software development a routine job people can be trained for. There are no routine jobs here. Routine work is done by computers.

JackOfAllTech
JackOfAllTech

With that attitude? And you're wrong on almost every one.

Tony Hopkinson
Tony Hopkinson

as a sanity check white board exercise. What it is explained in the problem. The test of sanity isn't that you get it right, but that you read the requirement. fiour sentences and I've seen people do something completely different... Equality and Equivalance. is V = 1 Y = 1 V = Y is equivalent x = 1 V and Y point at the the address of x, therefore they are equal. If you are in .net Declare two variables or type Guid and initialise them to the same GUID g1 != g2 if you do g1.ToString() == g2.ToString(), you will get true though becasue that's how == is defined for strings. It's a serious gotcha and leads to bugs that are very hard to spot by looking at the code. If polymorphism or inheritance cause bloat, you are doing it when you don't need to..... Though I'll admit there's a lot of that about.

gechurch
gechurch

If you find yourself disliking many of these questions, or not knowing what the answers are, you are probably the sort of candidate they are trying to weed out. I like the first question. Anyone with a reasonable grasp on two or three languages will know exactly what it is asking - it's not ambiguous (equality means they are pointing to the same object, equivalence means they are two different objects that happen to have the same value). This question does its purpose perfectly. Fibonacci is the classic example used for teaching recursion. I think any formally trained programmer will know fibonacci. If not it can easily be explained to the candidate, so the question can still be used. You will have noticed with all the proposed questions here, they are designed to: - Quickly weed out people who have poor skills - Find out how the candidate thinks through programming problems You can look at any of the questions individually and say they don't tell you much - you could be a great programmer and not know the answer. But as a set they give you a good idea of the candidate. It's impossible for someone to not know most of the answers and be a good programmer.

devonalds
devonalds

Well no. In the main, I agree with Tony Hopkinson. 1. Not everybody is recruiting from recent graduates. 2. It is self-defeating to put trick questions to applicants. 3. In fact, most of the 'techy' questions exposed here lack specific context - that may be ok if you are only interested in a specific language/environment; but surely your recruitment process would have filtered these already? If you are seriously looking for good people, general attitude and knowledge are much better indicators of future performance.

flmagman
flmagman

I agree that looking closely at their experience and understanding exactly what they've done is critical. Fibonacci? I don't really care whether they remember it, but more want to hear how they answer the question. Do they try to fake it or say, "Sorry, I'd have to look it up." If they hadn't used it, and I don't use it, I wouldn't ask the question. Polymorphism in a procedural language is overloading procedures or functions (at least in the one I use), and unless they had looked at Java might not have come across the term. I would be listening to see how they conversed with my programmers, because you can pick up clues as to their attitude and whether they'd be a good fit or not.

Slayer_
Slayer_

I question the purpose of the questions. If you wouldn't hire someone because they are not a robot that would jump off a bridge at your command, than I wouldn't want to work for you. -Edit, just noticed I wrote 9 as a prime number. Oops.

Slayer_
Slayer_

But I just never seem to need it in the work I do. ... I'll have to go back to school and freshen up if I ever want to change jobs. At least I do know what factorials are, again, never had a practical use for them. Nor do I know how to use them in code.

Jerriais
Jerriais

I admit, I have to think about Fibonacci in recursive terms: the obvious is the ! operator, If x = 1 THEN 1 ELSE x*(x-1) FI; that I can't for the life of me and a bottle of Merlot name at 3am. I find it significant that somebody can count 9 among prime numbers as separate from divisibility by 3 but it hardly matters. Most of these questions today relate to engineering and hardware design. 'Programming' consists of knowing how to mate visual control routines and little else. How they are implemented in bottom level logic matters no more than the electronic theory underlying semi-conductors. It's like asking a bus driver how to repair a blown gasket, no longer relevant and why I lost interestr in programming. Reverse an array without a loop? In APL that would be an operator and Algol-68 an assignment and let the interpreter/compiler sort it out - that's what it's there for. I admit that if you don't know how many cells you are dealing with or can't treat an array as a single entity (which most modern languages like C will not - in fact C won't even handle arrays at the level Fortran 2 would in 1957) it is difficult to imagine without a loop. Equality and equivalence have more than one meaning and asking for clarification should show awareness of that. Equivalence could mean identity of computer address or of binary value, so 16r30, 10r48, 8r60 and 2r110000 are all equivalent. Then again, if x and y are both references (C pointers) and both assigned to z then x and y are equivalent and if 'zilch' and 'zero' are defined as synonyms for 0 (INT zilch = 0; INT zero = 0; or I think in C #define zilch = 0; #define zero = 0;) or INT nix := 0; REF INT zilch = nix, zero = nix; (No idea in C or if it is even possible in overblown assembler!) then zilch and zero are equivalents both containing (pointing to) nix.

Slayer_
Slayer_

I searched on google, I see no such generic language possibility. The question in the blog didn't specify what language, so I am assuming it must be possible in every language. Frankly reversing with a loop is challenging unless you cheat and make a second array.

Tony Hopkinson
Tony Hopkinson

Never use that when there's another option. It looks good on paper, try to debug it and you disappear up your own arse in three calls. If want to test for recursion, problem should include a tree or some such.

Slayer_
Slayer_

Its not about what a programmer knows, its what they can learn. None of these questions address that. Equality and equivalence, if the question mentioned "memory" anywhere in the question, I would know what it was asking. But it did not. Also, its fairly useless knowledge as it mostly goes hand in hand with by reference and by value. If a programmer understands THAT difference, they are set. "Fibonacci is the classic example used for teaching recursion. I think any formally trained programmer will know fibonacci. If not it can easily be explained to the candidate, so the question can still be used." I took applied math in high school, this was never covered. I took a 2 year C/AP course for college, this again, was never covered. Most math problems were not covered aside from basic business math. Fibonacci is not business math, from a brief Wikipedia read, it looks to be geometry, which is often used in 3D programing. Such as video games. There are specific colleges and schools for teaching gaming programming. Game engine programmers need to know geometry and physics VERY well. I program for an insurance company, I need to know basic addition, subtraction, percents. Basically grade 5 math. If an interviewer said do you know Fibonacci to me, I'd say, No, but I like pizza, cause it's a stupid question. Actually, for my interview, I showed several mini programs I made at home, showed examples of my coding style and documentation, and told my interviewer my basic steps to solving problems. Once hired, the fella I shared an office with showed me around. My boss actually taught me how to use Crystal in their unique way (not with database connections like they teach in school). I just don't see the point in these questions. You want to see how they answer? What if they answer "I don't know, let's Google it"?

ejrg
ejrg

"It's impossible for someone to not know most of the answers and be a good programmer" Rather a bold statement isn't it, can you back this up with any evidence. Anyone can ask a question in their field of expertise, and I suspect like much of the rest of the computer industry, even programming as sub fields of expertise. If I asked a question about assembler would you be able to answer it?? (Please note I'm not a programmer, someone once tried to teach me Pascal, I fell asleep after reading one page of the text book). I think it is well known that the better programmers have Aspergers syndrome. Something about structure and repetition - it suits the way they think.

Tony Hopkinson
Tony Hopkinson

it. n! is number of ways you can arrange a sequence of n objects. The number of possible sequences of A,B,C,D, is 4 ! which is 24. save you working out how big an array you need to store them all. Not often it comes in handy, but it can. I use polymorphism a fair bit in my job.

gechurch
gechurch

You are correct that I know a limited subset of languages (and I use the term 'know' loosly - I don't market myself as a programmer). I have inadvertently shown my later point - that you don't know what you don't know. I could have googled the answer, but because I thought I knew the answer I didn't bother. And I was wrong. Fortunately this is just a forum and it doesn't matter. If someone had hired me to work on a project and I made a similar mistake because of my lack of knowledge, that could have a big negative impact on a project. I still believe this is a good question, precisely because it is ambiguous. There will be poor answers ("I don't know" or making something up), limited answers (like mine - knowing *an* answer but not realising there are others), and good answers ("It depends on the language, for example in java...").

Justin James
Justin James

If you are hiring for a Java job, the question pertains to how Java treats it. Ditto for C#, Perl, VB.NET, etc. I think that it should be pretty obvious that if you are hiring for a particular language, that the question is about that language. If it is a multiple language position, the candidate is free to ask for clarification. It's not like these questions are being asked without context. J.Ja

gechurch
gechurch

Stack size can become a problem with recursion. I'm not sure at what point it kicks in, but you're right - 10 million is a lot of calls to keep track of.

pratik_vaishnav
pratik_vaishnav

the function reverse should take array as a parameter(as you defined) but in recursively called function the parameter is value not array of value. return reverse(input[1-(input.length-1)]+input[0]) ---reverse(input[1-some int value]+int[0]) sorry if i'm wrong.

Slayer_
Slayer_

Sounds dangerous, what if its a 10 million element array?

gechurch
gechurch

A reverse function takes the first element of a list (eg. array) and swaps it with the last, then takes the second element and swaps it with the second last etc. Once done, iterating through the list from the end to the start will give you the same order as going from the start to the end of the original list. The previous commenter used recursion. The giveaway is that there is a call to the function from within the function itself. So it starts the function, gets part way through and then calls itself again with different paramaters, then gets partway through and calls itself again and so on. It does this until it gets to some stop condition, then the function returns to the previous call, which completes and returns to the previous call etc until the whole thing unravels again. That is why it isn't just swapping the fisrt and last - it keeps on gettingg called for every element.

mr_bandit
mr_bandit

If you are using a goto, you are creating a loop. Doesn't matter if you are using assembler or a high-level language. Loops in a HLL get translated to gotos (branches) in assembler. I don't think the recursive code fragment would work. However, the general concept would, but I didn't think of using recursion, and I have been in the biz for 35 years. The questions are not very useful for the embedded field.

rwparks.it
rwparks.it

I would use recursion to reverse values in an array using a higher level language. As a different approach. I would use the stack in assembly language.

Slayer_
Slayer_

It looks like your just swaping the first and last entries in the array. But the question was how do you reverse an array. Also, what is "reverse" function, where does this function exist? What does it do?

Justin James
Justin James

Recursion is the answer here: function reverse(input: array returns: array) { if input.length = 1 then return input else return reverse(input[1 - (input.length - 1)] + input[0] end function Is recursion a "real world use case"? Only in a few specialized fields. But it shows problem solving capabilities while thinking in the realm of code. And for the record, I took 2 semesters of CS in college, and a few years of "programming" in high school. I am hardly "formally" or "classically" trained in CS, so it's not like this is a personal bias coming out... J.Ja

Slayer_
Slayer_

I would say a loop would be a better choice then.

JackOfAllTech
JackOfAllTech

One way is by using integers to keep track of where you are in the array and using goto to jump around. In assembler you would use branches but that's beyond a VBr.

gechurch
gechurch

I agree with your first sentence. I consider what a person is able to learn is far more important than what they know now. Given a choice between someone who has the skills needed now but doesn't seem devoted to continual learning, and someone who knows programming in general fairly well and spends a lot of spare time programming for fun, I would always hire the latter. They will learn the skills the first candidate has and keep on learning. But there has to be a sound knowledge of programming principles. The group of questions this article proposes will test that, and in a language-agnostic way. That's why I don't consider my earlier statement bold at all. Any low-level, specific question can be googled easily. What can't be googled is the higher level stuff. Google won't teach you to think about how to arrange your program so that it scales well, and is hardware-independent, and uses the most appropriate data structure, or the best way to provide locking of data to ensure your program works with multiple CPUs without unnecessary slow-downs. Google is great for specifics, but it won't teach you how to think like a programmer. The other problem with google is a lot of the time you don't know that what you are doing is a sub-optimal or even bad way of doing things. It's a case of 'you don't know what you don't know'. If you're getting a compiler error because you are calling a function with the wrong types, it is obvious there is a mistake and you know to look it up. If you are doing something that is poor practice like incorrect use of globals, or not locking access to shared data you won't know that you are doing something wrong and therefore won't know to look it up (if you knew you were doing it wrong, you wouldn't have done it that way in the first place). The only way to address the higher-level issues like this is to read about programming concepts. If you're formally taught that's great - you are less likely to have gaps in your knowledge. But if not you can still get the knowledge by reading great books and blogs. By the way, my point about fibonacci is not that the math is important. Quite the opposite - it is a good choice because it is a simple sequence. If a candidate hasn't come across it, the interviewer can explain it and the question can still be used (I said this last time).

Slayer_
Slayer_

Again, definitely not true. How do you describe a good programmer? To me a good programmer is someone who gets their work done quickly, efficiently and with as little bugs as possible. I know how to read and write binary files in VBA/VB6, my co-worker doesn't even know that is possible. Does that make him a not a "good programmer". He produces the same work as me, very good quality and fairly timely. I am sure if he ever had a task that required binary files, he would either ask me how to do it, or look it up.