What is the best way to prepare code samples?
What are employers looking for when they ask for code samples and how should I prepare them? I am particularly interested in a Rails position where a code sample is required. I usually link to my Github account, but I'd like to know what experts on here would suggest for best practices and format.
Here are the things I look for when reviewing code samples.
1. Are the variable and function names self explanatory? For example, can a coworker quickly review your code and modify it.
2. Does the code follow standard formatting practices?
3. Has re-usable code been isolated as a distinct sub-routine or function?
4. Is it "tight"? It's not cluttered with unnecessary comments. It uses two-lines when only two-lines are required.
5. It works as advertised.
6. It's not trapping errors to avoid display versus preventing them in the first place.
7. Once no longer used components are "destroyed" to free up memory.
8. Loops "break" when the data you are looking for is found preventing unnecessary looping.
9. Similar to above "Case" is used for large "If/Else" and/or "if else" is used rather than a simple string of "if" statements.
10. The logic is linear but not necessarily synchronous.
11. Language specific functions are used rather than using multi-line code to achieve the same result.
Basically, code samples demonstrate you understand best practices, your code is quickly decipherable, do understand the language, and you're not creating unnecessary memory leaks.
Pick your best 3-5 rails projects from the last few years and showcase them on whatever site or platform they are on and show what code you contributed to each project. You could do this with presentation software if you felt like making it into a video or slideshow.
Github or bitbucket is a best option for sharing code rather than supplying in a zip format. Most of the employer looks at code structuring, comments/documentation, memory allocation, formatting and logic i.e. re usability of the code.
In some cases, you're not allowed to share code at that time you should supply few good logically based controllers, models and views in zip format along with short and sweet understandable description about what it does.
Would something like this be useful?