Even though only about 1 in 10 companies that I've contacted do this, I get worried about the dreaded request for code samples. With portfolio samples, the objective is easy, look for someone with visually pleasing websites that also fit the style they are looking for. But ironically, with code samples, I cannot understand how they think they can project a lot about my technical skills from a few short source files.
A company's HR staff contacted me for a PHP developer position recently and then told me that the hiring manager (a technical lead) asked for some code samples.
I asked him what samples would fit the requirements they are looking for and the HR person said that he is not sure, but two files would do. I sent him two files, both from different projects and the code was for different purposes to show the versatility in my work. The context of each was explained a little in the e-mail.
Afterwards, they told me that I wasn't considered to move forward with the hiring process. But more interesting was that they also said they had a bit of difficulty aligning my relative expertise to what the position is about.
Am I just bad at picking code samples? Was my syntax formatting bad? Lack of proper documentation? They didn't say. Besides, with syntax formatting, every company has their own conventions that they follow and adapting to it is a trivial aspect to me. When a design portfolio gets rejected, you can safely assume that they did not like your designs, but I feel like I have to read someone's mind when submitting code.