Programming: suggestions for code example

I have an interview (for a programming job) next week, and I’ve been asked to bring along an example of my code, and briefly describe it.
Alas, the only spec I have is “some C++ code”, and I feel like I’ve left it too late to ask them for more detail. Also I need to write it from scratch.

Should I write code that highlights a well thought out class heirarchy? Show that I know a number of design patterns? The most bulletproof code? Something executable (bearing in mind executable code will involve overhead / bloat)?

I’m having “programmer’s block” right now…

Do you keep in contact with any classmates or current/former project collaborators you can contact for any work you’ve done? That could be a source

Copy-paste from a program you’ve written in the past and be prepared to explain it is what I would do. I’d bring the top section, where I do any package imports and variable definitions/initializations, and maybe 20-30 lines beyond that. They’re probably looking for things like if you comment your code, how readable it is, if you use good strong indentation which highlights the syntax, meaningful variable names, etc. I wouldn’t write anything for this assignment. Surely you have a library of your code, useful classes/functions, etc. that you keep lying around that you could copy paste from?


Why do you have to write it from scratch? Given the other requirements, I would be inclined to bring in some non-encumbered work that I had previously done. Are your interviewers telling you that you must do something new for them, or is it just that you don’t have anything that you’ve previously done in C++?

BTW, despite my respect for him, I have to question Mtgman’s assessment. Part of my job is to interview programmers, and if I had offered that challenge, I would be looking for a candidate to present me with something that demonstrated insight beyond attention to the superficial.

I’m away from home right now and don’t have anything too recent, or anything that I’ve done commercially to hand.

Still thinking…
I’m leaning towards a shader demo now. Even though they said “C++” and not “Direct3D / OpenGL”.
There may be some graphics work in this job (sorry didn’t mention that in OP), and I’m thinking this might impress more than a class heirarchy. Just a simple demo, clearly-written.