If you’ve landed here, you’re probably supposed to submit a solution for a take-home coding exercise shortly. I’ve been in the same situation a few times and each time learned more. Based on my experience, to pass a coding exercise you should follow seven rules which sometimes are ignored even by senior candidates.
1. Don’t Rush
Normally you’ve given a fair amount of time to submit the solution and most of the time it doesn’t really matter to do it quicker than usual. Hence, there is no need to rush or look for shortcuts, instead deliver your best piece of work. Remember this is not a contract job, the more time you spend, the higher chance of going to the next round you have.
2. Review the Requirements Thoroughly
Before writing any code make sure you’ve completely read and understood every single requirement. It doesn’t matter how good your code is if it doesn’t cover what you’ve asked for. This is also an opportunity for you to show you have a strong attention to detail.
3. Ask If You’re Not Clear
There is nothing wrong with asking for clarifications if you’re not clear. Depending on the task, questions might be around the submission instructions, requirements, time frame and tech stacks that you can use. In most cases HR team is happy to help. It also proves you’re able to communicate and collaborate effectively.
4. Overkill the Code Quality
Regardless of the size of the coding exercise, you should put a lot of thinking into the design and start with a good foundation. You can probably explore your approach using class and activity diagrams if applicable. Remember, the goal isn’t only to build something that works, but also to make a piece of art considering efficiency, extensibility and reusability. In short, your application must be performant and maintainable. I’m not going into much details but:
- Start with tools and technologies you’re most comfortable with
- Pick a good IDE and enable all the code quality checks and lint tools such as SonarLint to avoid potential errors
- Use version control even you’re not supposed to publish the code in a repository
- Set up an organised folder structure with a good file and folder naming convention
- Follow a coding style guide such as PSR-2 for PHP or PEP for Python
- Always think of architectural principles such as DRY and SOLID
- Utilise new features in the programming language you’ve chosen
- Leave comments to improve code readability. This is not only helpful for the one who reviews your code but also yourself in the next possible on-site interview when trying to explain your solution
- Make sure auto generated files and folders such as code coverage and dependencies folders are not included in the submission
- Review your code again and again
Finally, think about different scenarios that can extend the existing challenge and keep the application modular and flexible enough to allow extending it easily during the on-site interview. Having said all of these, keep your solution simple and avoid any complexity.
5. Write Automated Tests
Having automated tests is a must have for a coding exercise. Depending on the project try to improve the test-coverage by writing good unit tests specially for the main functionalities without over testing them. Write the test in a way that if it fails it’s easy to identify which part causes the problem. Also keep in mind that TDD approach is always an advantage. Finally, consider front-end and end-to-end browser testing if applicable.
6. Don’t Forget the Documentation
Let’s face it, majority of programmers are not good at writing documentation. But when it comes to a coding challenge you should put yourself in the user’s shoes. The
README file should at least include:
- Minimum requirements for running the app
- A list of major third party dependencies
- A detailed step-by-step guide on how to install the app
- An explanation of the app usage including a few examples
- Instructions for running the tests and generating the code coverage
- A walkthrough of the design, assumptions and why you picked approach A over approach B
To make sure you haven’t missed anything try to install and run the app one more time from scratch.
At the end of the day, a take-home coding exercise is a challenging problem to solve at your own pace which is exciting! As an engineer, I’ve personally enjoyed doing it every time and devoted myself completely to it. Also it’s an opportunity to experience and learn something new. If you’re thinking to improve your portfolio, you might be able to have the solution excluding the challenge description in your public repository but this needs to be checked with the HR team first.
I hope this has been helpful but don’t get disappointed if you fail and ask for feedback instead. Then next time you know what needs to be focused on. If you’re struggling with coding I suggest you to join Pairoject and pair with someone more experienced to work on a side project. Reading other people’s code and contributing to open-source projects are other ways of improving your coding skills. All in all, good luck and have fun!