One of the biggest fears for a newbie developer is the dreaded 'coding challenge' that is a popular part of job interviews. This fear often gets in the way of applying for the position at all!
I completely understand as I also felt the same way when I was starting out. I believed that, unless I could submit code that worked, was structured in a way that would make Sandi Metz proud, and had 100% test coverage (with all tests passing), I was wasting my time and theirs.
But these coding challenges are not intended to catch people out. There is a shortage of developers - trust me - we want you to succeed! The code you submit does not have to be 100% perfect. It is more about providing an insight into how you work.
If you are struggling, forget the fancy tricks and just code a brute force solution. It still shows that you know how to write code. Don't forget to include some documentation and write tests. As a junior developer, we are looking to see that you are thorough, that you set high standards for yourself, and that you can be taught. As long as you acknowledge that this is a simple brute force method, it provides a starting point for a conversation.
From the coding challenge, we want to learn the following about you:
- Do you pay attention to the requirements?
- How do you approach a problem?
- Are you 'done' as soon as the code is running, or do you take the time to refactor and clean up any inefficiencies?
- Do you include documentation and comments in your code?
- Do you create and run tests? Similarly, do you do enough testing?
- Does the thing actually work when you say it works?
- What technologies do you use?
- What kind of design decisions do you make?
There aren’t really right or wrong answers to these questions, they are simply a way of gaining an insight into how you work.
A good company will follow up a coding challenge with a pair programming session to work through and discuss any issues. The developer you are paired with will ask you pertinent questions that are intended to guide you towards identifying the issue yourself, and then work with you to correct them. Even if you do not get the job, you can learn more during this pair programming session than you would have in several days - or even weeks - of self-study!
In summary, do not be afraid to apply to a job that includes a coding challenge. The employer does not have unrealistic expectations of you and you will not be judged unfairly. And - worst case scenario - it is a wonderful learning opportunity to spend time with a senior developer and identify where you should best focus your future learning efforts. Good luck! :-)