9
\$\begingroup\$

We've had Stack Snippets for a few months now, and a few nice snippets have been written, which will probably come in handy time and time again. It's been brought up a few times in chat, that it might be nice to collect these on meta, so we don't have to reinvent the wheel for each new challenge.

The first question is: does anyone object to that? If so, why?

However, even if we do want to collect these there are several ways we could structure this, and it would be nice if we decided this upfront, so that it's consistent.

  • Post a single meta question, The Snippet Toolbox, where each answer contains a single snippet. Feature requests and bug reports go in the comments.
  • Post one meta question per snippet task, e.g. "Do we have an existing Stack Snippet which generates leaderboards for code golf challenges?" Each answer would contain one snippet implementing the task (so we might have multiple snippets for the same purpose). Feature requests and bug reports go in the comments.
  • Post one meta question per snippet. This could work like StackApps. The question itself contains the snippet, whereas answers are used for bug reports and feature requests - either in a single CW answer, or across multiple answers so that votes can indicate urgency.
  • Any other format I didn't come up with.

Which format should we use and why?


As per Peter's request, a few snippets we already have:

And a few snippet ideas we could probably use, but which I haven't seen yet:

  • A pair of leaderboards/dashboards for cops and robbers challenges.
  • Mostly for challenges with list-like input, a snippet which converts the test cases to the most common list formats would be nice.
  • ...and who knows what else we might come up with in the future?
\$\endgroup\$
5
  • \$\begingroup\$ This question needs more context before it can sensibly be discussed. Can you link to these "few nice snippets"? \$\endgroup\$ Jan 18, 2015 at 15:51
  • \$\begingroup\$ For the record, I never wrote that calculator; KennyTM was the one who actually edited it in. People keep attributing it to me, though. :P \$\endgroup\$
    – Doorknob
    Jan 18, 2015 at 21:58
  • \$\begingroup\$ We had a recent discussion like this one on Worldbuilding.SE, and found it helped to add each option as an answer and have the community vote on them. \$\endgroup\$
    – ArtOfCode
    Jan 23, 2015 at 15:04
  • \$\begingroup\$ @ArtOfCode That's what we're doing, no? \$\endgroup\$ Jan 23, 2015 at 15:07
  • \$\begingroup\$ @MartinBüttner Ah so we are. Consequences of not reading properly \$\endgroup\$
    – ArtOfCode
    Jan 23, 2015 at 15:17

4 Answers 4

9
\$\begingroup\$

Snippets go in questions, StackApps-style

Why I'm not a fan of a single meta question: it's the definition of "too broad". It's just going to be a huge collection of snippets, where the relative votes won't even have any real meaning (they'll just indicate how often a snippet is used, not how good the snippet is at what it's doing). Also comments seem a bit restrictive for bug reports and features requests.

Why I'm not a fan of one question per purpose: the idea of collecting the snippets is not to reinvent the wheel. So I don't think it will be very useful if everyone posts their own snippet and then you have to sift through half a dozen of snippets for the same task to decide which you like best. I'd prefer people working towards making a single snippet for each purpose the best it can be, and making it configurable for its different use cases. And again, comments seem a bit restrictive for bug reports and features requests.

Why I think putting snippets in questions is a good idea: it works well on StackApps, which is the only comparable concept we have on the SE network (afaik). It allows full answers for feature requests and bug reports, which can contain more detail, and voting lets the more important requests bubble up to the top. It might motivate people more to collectively work on a single good snippet, instead of everyone providing their own, marginally different, snippet for the same task. A list of all snippets can still be found easily, if we simply use a tag for all questions like this.

\$\endgroup\$
3
  • \$\begingroup\$ I think you meant "to not reinvent the wheel" in your second paragraph (not enough rep to edit). \$\endgroup\$
    – Scimonster
    Jan 22, 2015 at 13:10
  • 1
    \$\begingroup\$ @Scimonster Split infinitives and stuff. Although I do agree it's ambiguous in this case. \$\endgroup\$ Jan 22, 2015 at 20:36
  • \$\begingroup\$ I'm not sure I'm convinced that comments are restrictive for bugs/feature requests. In challenges, if you notice a bug in a user's program, you put it in a comment. Once that comment is no longer relevant, it can be deleted. \$\endgroup\$
    – mbomb007
    Aug 14, 2015 at 20:14
5
\$\begingroup\$

I'm not very convinced by any of the three suggestions in the question, because of this:

  • ... Feature requests and bug reports go in the comments.
  • ... Feature requests and bug reports go in the comments.
  • ... answers are used for bug reports and feature requests ...

The StackExchange model isn't designed for software development. Looking at StackApps, a number of the apps link to GitHub for the code, feature requests and bug reports, etc. And looking at the current userscripts and suggested future directions, it seems a lot more sensible to have the code in a system which allows forks to handle variants, pull requests rather than patches whose whitespace has been mangled, etc.

In view of the possibility (likelihood IMO) of forks which might want to merge or cherry-pick changes from each other, I think that the best model is one question with an answer per snippet which will as a general rule link out to GitHub or BitBucket. That way only one question gets bumped when three related snippets are updated.

\$\endgroup\$
7
  • \$\begingroup\$ Or we could always have a "master" Github repo that contains all "official" snippets, so that they're not all fragmented out over different repos and links. \$\endgroup\$
    – Doorknob
    Jan 19, 2015 at 2:58
  • 2
    \$\begingroup\$ @Doorknob, someone would have to maintain that though, to accept pull request etc... \$\endgroup\$ Jan 19, 2015 at 8:53
  • \$\begingroup\$ @MartinBüttner I'd be ok with doing that \$\endgroup\$
    – ArtOfCode
    Jan 23, 2015 at 14:45
  • \$\begingroup\$ @ArtOfCode Oh, so would I, but I don't think it's a good idea for the community to have to rely on a single person, no matter how active they are. \$\endgroup\$ Jan 23, 2015 at 14:50
  • \$\begingroup\$ @MartinBüttner Does GH not support multiple repo owners? \$\endgroup\$
    – ArtOfCode
    Jan 23, 2015 at 14:57
  • \$\begingroup\$ @ArtOfCode It does, but then you'd have to add every single PPCG user to it. I really don't see an issue with maintaining them in separate Gists. \$\endgroup\$ Jan 23, 2015 at 15:01
  • \$\begingroup\$ @MartinBüttner Or perhaps a select committee to maintain them. I agree, though, and however we do it we'll need to link it here \$\endgroup\$
    – ArtOfCode
    Jan 23, 2015 at 15:02
-1
\$\begingroup\$

This answer only suggests an organization of problems and solutions. Whether those solutions link to GitHub, link to BitBucket, or simply inline the code I think is getting way off topic here.

One problem per question, one solution per answer

If a snippet is useful, then by definition, it must solve a problem. Transform that problem into a question and post it. You can now get feedback in the comments. It's like playing Jeopardy but with more effort.

Let's assume that snippets are the solution to your problem (after all, you do know best). It makes sense then to allow for multiple snippets to compete for votes until one reigns supreme. If you are too busy to read them all, you can sort them by votes. That's what Stack Exchange was designed for.

Now remove that assumption. Maybe someone has a better solution that doesn't involve Stack Snippets. They can post it, compete for votes, and get feedback in the comments.

Alternatives

First alternative: The "Snippet Toolbox", described as a huge collection of snippets. The question could only be "Post a snippet that solves any problem." That's the definition of too broad. Also, the best solution to a specific problem has no way of rising to the top.

Second alternative: Post the snippet in the question. It calls for answers to be re-purposed for bug reports and feature requests. Feature requests belong in a new question (I am not suggesting that you post "Give me code please." A feature request is a new problem in disguise. You should describe the problem and state what you did to try and solve it. In other words, follow normal Stack Exchange standards for asking good questions). The community then has the opportunity to vote on it like any other question, including closing it as a duplicate or otherwise marking it off topic (too broad, unclear, etc.). Comments work just fine for reporting bugs. They exist for suggesting edits and requesting clarifications.

Just let the best (most bug free?) solution be voted to the top. That is what Stack Exchange is designed for.

\$\endgroup\$
-1
\$\begingroup\$

Stack Snippets don't belong in Meta

Meta is not a repository, it is a place "where users discuss the workings and policies of Stack Overflow rather than discussing programming itself".

While Stack Snippets contribute to the workings of our site, they aren't discussions. If the purpose of the post was to discuss a certain stack snippet, then it is acceptable, but simply posting a Stack Snippet isn't what meta is for.

Furthermore, we aren't really struggling from duplication of snippets. We simply aren't reinventing the wheel each time, so why are we trying to solve a problem we don't have?

Furthermore, collecting the snippets doesn't make them any easier to find. A person who would even consider using a particular stack snippet is the one who has seen that stack snippet before, and therefore the person knows where to find that stack snippet. A snippet in action is better advertisement than a snippet found in a long list of others.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ "and therefore the person knows where to find that stack snippet." I doubt that. Just because I know a snippet exists doesn't mean I remember where I saw it. Also, another big advantage (in my opinion) of having them on meta (which I probably should have mentioned explicitly in the question), is to generally increase awareness that the snippets exist, and to make it easier for people to reuse them. Even if people know a snippet was used on another question, they're less likely to rip it off there than taking it from a list that says "community-curated stack snippets". \$\endgroup\$ Jan 31, 2015 at 15:18

You must log in to answer this question.

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