6

Should we encourage people to show off interesting code snippets here? With the flexible nature of WordPress, you sometimes can do nice things with a few lines of code. Currently, we one see them if someone poses a similar question and you are around to answer with your own code.

It is allowed, and even encouraged, to share your knowledge about problems you encountered so others can learn from you. Should we extend this from the maybe more typical "small" Stack Overflow questions to code snippets that might be useable in wider cases?

If we do so, should we keep some guidelines in mind? How do we keep this clear for others who might see it as a "real" question and put effort in an answer? How do we prevent this from getting a messy bag of unassorted snippets, where nobody can find anything?

  • 2
    I think, yes code-snippets should be possible (and I think they are). Often some little code can do a lot with WP. – hakre Aug 14 '10 at 10:21
  • hakre, I think Jan is asking if we should allow users to "ask a question" when they only intend to share/show off a code snippet. – Travis Northcutt Aug 17 '10 at 14:28
  • @hakre: Indeed, I was talking about showing code you had written in the past for a specific problem. Is it OK to create a question where you state this problem, and then give your own code as an answer? – Jan Fabry Aug 17 '10 at 15:30
4

I could see someone proposing a hypothetical question - how would you address XX situation - as a Community Wiki. Then you could answer your own question and post a code snippet. If nothing else, you might get some interesting alternatives (that might improve on your code).

But these kinds of questions - since they aren't really questions, but discussions - should always be marked as Community Wiki ... otherwise I'd view it as blatant self-promotion and spam.

  • Interesting suggestion indeed: be clear that answers upvotes are only for the code, not for self-promotion. – Jan Fabry Aug 17 '10 at 15:29
  • 1
    I agree completely. Adding your own questions only to answer them yourself appears very disingenuous to me. +1 for Community Wiki. – MikeSchinkel Aug 17 '10 at 17:59
  • 1
    There are times when I think I've solved a fantastic problem with an elegant piece of code ... only to find out later that it was a widespread problem that someone else solved with a better piece of code. I think a Community Wiki would be an excellent place to discuss those issues and offer potential solutions - and the CW format prevents people from trying to farm reputation points or come off as disingenuous for answering their own question. – EAMann Aug 17 '10 at 18:10
  • I think this is an excellent way of addressing the issue. Kudos to you, and as they say, "I wish I had thought of that". – Travis Northcutt Aug 18 '10 at 12:20
0

Jan, I sympathize and to some extent would like to see that happen, but I don't think the current structure of the site allows for non-question code sharing to take place in a way that would be best for the overall health of the site. However, I would suggest that we encourage the owners of StackExchange to make modifications at some point that would facilitate this behavior.

  • Indeed, the snippet should be an answer to a question or problem, to stay in line with the site. This would also encourage all users to give other solutions to the same problem, and let the community decide by voting. I do not like general snippet sites because there is no way to let the best solutions stand out. – Jan Fabry Aug 17 '10 at 15:27
0

In think this question is related, as is my answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .