How to Select and Prepare Great Code Samples

1. Is the code clean, clear, and coherent?

There’s a joke amongst developers that you should write code as if the person who needs to maintain it is a violent psychopath who knows where you live. I want to hire developers who write code that others understand and enjoy maintaining. To that end, I expect samples to be readable and well-formatted. I expect methods and variables to be named clearly. I expect to be able to understand at a mere glance what a block of code will do. I don’t want to see clever, showboating code; I want to see code that anyone could read and understand.

2. Is the code well-documented?

Great inline documentation is the sign of a mature and thoughtful developer. When I read code samples, I hope to see a good balance of inline documentation. No documentation is lousy, as is too much. Inline docs should add to the code, not repeat it.

3. Is the code novel?

I’ve seen plenty of code samples that are little more than a call to WordPress’ register_post_type(), or something along those lines. That's akin to applying to be a chef and cooking off-the-shelf mac and cheese to demonstrate your abilities. If you want to cook in our kitchen, you need to demonstrate that you can prepare a novel dish on your own. When I read code samples, I want to see some flavor. I want to see code that solves an interesting problem, and does so as simply and elegantly as possible.

4. Does the code show understanding of the problem it solves?

I see many code samples that are obvious Frankensteins of Stack Overflow snippets, copypasta that a developer stitched together without proper understanding of how or why it works. That’s not to say that using solutions found on Stack Overflow is a bad thing — certainly not! But it can be fairly obvious when a developer pastes something in that they don’t understand, especially when part of that code has literally no impact on the function in which it runs.

5. Is the code good?

Lastly, I want to see if the code is, as objectively as possible, good. Is it performant? Is it secure? Is it over- or under-engineered? Would I deliver this code to a client?



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store