Idea: "Wiki" Code Snippets at the top of Forum Threads

This is just a short, half-baked idea that I'd love some feedback about.  It's pretty common in the forums for users to post a code snippet in their question, say "Hey! This isn't working!" and then having a conversation with the community about how they should fix their code so it works.  The problem is that people have to keep copying and pasting the code block over and over again, or they just don't bother, and it becomes fairly difficult to follow the thread.

Why not have a little wiki-style area at the top where any contributor to the thread could edit the code sample, slowly turning it into a quality piece of code.  Just like a wiki, moderators would be able to control it, and a history would be kept.  The code snippet could be locked down (maybe when the question is marked as answered?)  Then, at the top of answered questions, you'd have a community validated code snippet.

Here's my mockup of what it might look like.  What do you think?

Comments

  • Anonymous
    December 08, 2006
    I think you'd want multiple snippets (one per user per thread?), for when there are multiple variants.  Add a "quote code" when spinning up a new variant. If a code validator were present, that'd be cool.  Could include standard .NET libraries.  Nothing really complex (eg, no editting of msbuild targets, or anything that might risk security). A real code pretty-printer would be nice, too, but probably limited in this case.