John said:
We ask them to bring some code samples. Some claim that everything
they've ever written is proprietary to some company, so they can't
show us any.
They probably have no joy in writing programs - poor guys.
The code tells the story. Most of what we have seen is ghastly.
Styles differ - from your other posting I see that you have some special
expectations. I find most code ghastly, too, but maybe for different
reasons ;-).
A program should start with context: who wrote it when, what it does,
what compiler/processor it's for, what is its revision history,
anything else that would be useful. And it should be carefully
commented alongside the code. A quick "coding" test won't show that.
Hm, a significant part of what you are looking at here is in the VCS, not in
the source. Like who wrote it when (blame command), revision history (log
command). Programming is about using tools. Not using a VCS is worse than
just writing ghastly code.
Comments? Depends on the strategy. For some projects, literate programming
is appropriate - e.g. you teach the user how to write such a software, and
understand the rationale behind. If you do test-driven development, your
documentation would be a spec plus tests. If you write a library, you would
use something like doxygen, where you document the use of each function
together with its implementation. The purpose here is to produce a user
manual out of the source code.
Actually writing in plain text what you already wrote in the programming
language (typical assembler-style along-side documentation) is IMHO not
good style for high level languages. Using proper function and variable
names helps a lot, more is only for the reader who doesn't understand the
programming language. This is pointless most of the time - a programmer
must understand the programming language he uses and read it as fluently as
English text. Comments like
a += c; // add c to a
foo(a, c); // call foo with parameters a and c
don't add any value, except if the program is meant as beginner's
introduction into this particular programming language. Most projects
shouldn't fall into this category.
Most of the code we see is just a jumble. You have to figure out what
version of which language it's in (C? C++? Java? Python?) by examining
it line by line. Ditto trying to find out what it's supposed to do.
Language should be already identified by file name extension - what it is
supposed to do (briefly) by the file basename - at least for the smaller
programs you could discuss at an interview (larger programs might have
code-named parts, where you can't see function from filename. My widget
library is called MINOS, the widget editor Theseus - the programs live in
files with these names - of course, the first line in these files describe
briefly what it actually is). When you look on printouts, use
frame-generating software like a2ps (including syntax highlighting).