Creating good example code is hard

It's hard to come up with good example code in documentation, something I plead guilty to in my own writing. Another example, which I guess lots can identify with, is the documentation by Microsoft. When I search the documentation, it's usually the code examples I look at first, and, for some reason, the code examples most often miss the point...

The other day, a colleague sent me a code snippet from a piece of documentation he had written and it was just great! He didn't invent the example, but took it from real life code. Perhaps harvesting code samples is the thing to do, just like harvesting frameworks has proven to be a good idea rather than inventing them.