From the author: I developed and conducted dozens of programming interviews. Here I will tell you how to beat me
Let's be honest, most programmers do not like to write code at the interview. Some even
threaten to leave the profession for this reason. But in the near future nothing will change. So if you really want to get a job, you'll have to figure out how to succeed in these interviews. I will help you. We will study the process, and I will explain what I want to achieve from the interview, so that you will have a fairly clear idea of ​​how to go through it.
Before I begin, I just want to say that if a company is going to hire a developer
solely and
exclusively on the basis of a code fragment that he wrote at the interview, then you probably will not want to work in such a company.
')
You're more than just a coding machine.
Part 1. Programming on the board
Who is programming on the board in this world? In fact, seriously. However, I will ask you to do it. Don't worry, I haven't lost my mind. I know about Google and that the board does not do well with autocompletion. I don't care. I check not how beautiful the code you write on the blackboard, but something else.
When you get the job, you
never have to program on the board. But I guarantee that the moment will come when we all will puzzle over the problem before the deadline, when we are exhausted to the edge, we are all angry, and our work and reputation are at stake. When such a moment comes, we will go to the meeting room, pillar near the blackboard and find out what to do. Quickly.
"I check not how beautiful the code you write on the blackboard"
Although I do not need a programmer who writes beautiful code on the board, but I need someone who is able to think quickly on the go, under pressure, in the same room with others. The problem is that if you do not understand what I check, then you will do everything wrong. You are going to prove that you are a true ninja in board programming. This is stupid. Nobody needs a ninja in board programming. Here's how to beat me:
1. Verbalize your assumptions and try to confirm them.
The best developers know that, in a fundamental sense, every bug is the result of an incorrect assumption . So before you start writing code, think about the necessary assumptions and ask me about them.
2. Think out loud
I want to get some insight into your thought process. For me, your thoughts about the problem are much more valuable than knowing the names of some built-in function by heart. So think out loud. Say everything that comes to mind.
3. Do not be afraid to ask for help.
If you are stuck or do not know something, ask me. You can not imagine how fantastically expensive the company is costing a developer who refuses to ask for help when he is stuck somewhere. I don’t have time for a programmer who doesn’t give results, because he pretends that he has everything under control, and he himself is helplessly wallowing alone.
4. Honestly show your abilities and experience
I do not want to deceive you with the previous advice. There is a certain level for questions and comments. If you are asking about what should be obvious to a person with relevant CV entries, then this is a red flag. So before you start programming on the board, make sure that you are honest with me in representing your abilities and experience.
Part 2. Computer programming
Unlike the board, if I invite you to the computer and ask you to write the code, then I
really check how well you are programming. More precisely, I test your ability to
abide by the rules .
It is best to understand this, if you look at a real example. One of my favorite questions is:
A palindrome is a number, combination of letters, a word or text that is equally readable in both directions. Adjustments to capital letters, punctuation and spaces are allowed. Some examples in English are: “A man, a plan, a canal, Panama!”, “Amor, Roma”, “race car”, “stack cats”, “step on no pets”, “taco cat”, “put it up ”,“ Was it a car or a cat I saw? ”and“ No 'x' in Nixon ”.
Write the most efficient function you can find to determine if a given string is a palindrome.
Your function should take a string as a parameter and return a boolean value ( true if the string is a palindrome, and false if it is not).
Suppose that this code will be delivered to a real system on a working server, and write accordingly with this.
When I offer such a task at the interview, the first thing I do is see if you ask me additional questions or not. As I said before, the best programmers understand that assumptions are what kill you in this business. My advice to anyone who has received instructions for writing code is to pause and think about what assumptions should be made in order to complete the task (they always exist) and find a way to confirm or clarify these assumptions. I understand that during the execution of the task, people go to the "test mode" and think that they are forbidden to speak. I suppose that you will start with the question to the interviewer: “Am I allowed to ask you one or two questions in order to clarify some assumptions?” (I always answer “yes”), and then you will get a HUGE advantage.
Good questions for this particular task:
- Is here client javascript or server side?
- In the context of this task, can an empty string be considered a valid input string?
- Do I need to handle unicode characters?
Next, I see how well you follow the instructions. For example, I defined a string as a parameter and a boolean value as the result. Is this what the program gives out?
Then I want to see how you interpret the phrase "Assume that this code will be delivered to a real system on a working server, and write accordingly with this." If you have previously developed a working software, then you understand that this phrase means several things:
- There should be comments in the code.
- It is necessary to provide error handling or at least logging.
- The program should impose tests.
- The program should not fail in any way.
- The code should be easy to read and speak for itself (easily understood variable names, good formatting, ideally - without complicated structures and defects (“lint free”)
If you have previously seen the code only in textbooks and manuals, then you do not know what the above-mentioned things mean. My advice: look at the code for popular open source projects. Especially those projects that have been developing for a long time and are stable. For javascript, jQuery code on github is a good example.
Further, it is interesting for me to see how you understand the word “effective” in combination with the “production system”. If you have experience, then you understand that the concept “effective” for a program in production means three things:
- It works fast.
- Does not take memory when she does not need it.
- Stable and easy to maintain.
You should understand that point 3 sometimes means some damage for points 1 and 2.
In this particular problem, I assume that many will use regular expressions here. They are universally suitable for many languages, fast and extremely convenient (
editing : regular expressions do not
always work quickly, including with a palindrome, thanks to
AlexDenisov in the comments). It would be quite reasonable to assume that you know the basics of regular expressions, but you can still write code without them.
As for the tests, I want to see that you provide for many tests, but they will all check out really different scenarios. Checking “mom”, “dad” and “racecar” is redundant, it's all the same test. I also expect to see that you turn on strength tests (crash tests); tests of any strings that are not palindromes. Consider borderline cases, check zero or number. Check the empty string or set of special characters.
I set this task to developers at all levels, but the more experienced the specialists, the stricter the criteria.
If the junior gives a workable and fairly simple solution, and all the rest of the interview is normal, this is enough to get started and improve your skills.
For mid-level developers, I want to see some comments and a good programming style. I want to see an effective solution, and perhaps some kind of test.
For leading programmers, I would like to see the optimal solution, clean and supported code, error handling, comments, a complete set of tests. For example, if you use
console.log () in JavaScript on the client side, then add a comment that makes it clear that you are aware of the need to support logging also on the server side.
Here is
an example of good code written in javascript.
'use strict';
Obviously, there are other ways to write a suitable program, but this gives an idea of ​​what I'm talking about.
If I give a home task, then the expectations are even higher.
Part 3. Algorithms
Some interviewers will ask you to write an implementation of a specific algorithm. Personally, I think this is a huge waste of time. It is much more important for me that you understand which algorithm to use for which task. Implementation can always be found in Google.
However, since interviewers will ask for this, it is better to refresh the knowledge in the memory before the interview. There is a great
free course at Khan Academy.
Part 4. Do not give up without a fight
If you are not able to solve the proposed task, there are always some things you can do to save the chances of getting a position.
1. Don't give up too easily.
Make sure I notice your efforts. If you are one of those who give up when it becomes difficult, I will not waste time on you.
2. Pseudocode
When the problem arose from the fact that you cannot remember the exact function name or another syntax rule, use comments to explain what you want to do in the pseudo-code. If I get the feeling that a single request to Google is enough for you to solve a problem, it will not affect a positive result. Especially if you showed yourself perfectly on the rest of the interview.
3. What are the known unknowns?
If you are completely stuck, the last option remains: tell me everything you need to know to solve the problem, and tell me how in the real world you will get this information. Tell as much detail as possible. If you say that you need help, then tell me who to contact (position) and specifically what to ask (the most specific question, if possible). If you say that you search on the Internet, then name the specific search queries by which you will search. In this scenario, you need to convince me that you can really solve the problem in real life if you work for me.
Part 5. Practice, practice, practice
Perhaps the most important thing for a successful programming interview is good preparation. It’s best to practice with standard questions again and again until you learn them by heart. If you train a lot, you will be able to answer questions that you have not met before. You will have confidence and you will be able to connect any question with something else that you have met before.
I have compiled a large list of online resources with sample questions and programming tips for 50+ different programming languages ​​and technologies, including C #, JavaScript, Mongo, Node, and so on ...
The list
here (subscription to the newsletter) and in
pdf .